Вы можете использовать Python SDK для Dialogflow для создания типа сущностей и сущностей.
Вот основной код, вы можете изменить его в соответствии с вашими потребностями:
def create_entity(project_id, entity_type_id, entity_value, synonyms):
"""Create an entity of the given entity type."""
import dialogflow_v2 as dialogflow
entity_types_client = dialogflow.EntityTypesClient()
# Note: synonyms must be exactly [entity_value] if the
# entity_type's kind is KIND_LIST
synonyms = synonyms or [entity_value]
entity_type_path = entity_types_client.entity_type_path(
project_id, entity_type_id)
entity = dialogflow.types.EntityType.Entity()
entity.value = entity_value
entity.synonyms.extend(synonyms)
response = entity_types_client.batch_create_entities(
entity_type_path, [entity])
print('Entity created: {}'.format(response))
Вам нужно создать entity_type, вы можете сделать это, используя следующий код:
def create_entity_type(project_id, display_name, kind):
"""Create an entity type with the given display name."""
import dialogflow_v2 as dialogflow
entity_types_client = dialogflow.EntityTypesClient()
parent = entity_types_client.project_agent_path(project_id)
entity_type = dialogflow.types.EntityType(
display_name=display_name, kind=kind)
response = entity_types_client.create_entity_type(parent, entity_type)
print('Entity type created: \n{}'.format(response))
Надеюсь, это поможет.