def create_session_entity_type(project_id, session_id, entity_values, entity_type_display_name, entity_override_mode): """Create a session entity type with the given display name.""" import dialogflow_v2 as dialogflow session_entity_types_client = dialogflow.SessionEntityTypesClient() session_path = session_entity_types_client.session_path( project_id, session_id) session_entity_type_name = ( session_entity_types_client.session_entity_type_path( project_id, session_id, entity_type_display_name)) # Here we use the entity value as the only synonym. entities = [ dialogflow.types.EntityType.Entity(value=value, synonyms=[value]) for value in entity_values ] session_entity_type = dialogflow.types.SessionEntityType( name=session_entity_type_name, entity_override_mode=entity_override_mode, entities=entities) response = session_entity_types_client.create_session_entity_type( session_path, session_entity_type) print('SessionEntityType created: \n\n{}'.format(response))
def delete_session_entity_type(project_id, session_id, entity_type_display_name): """Delete session entity type with the given entity type display name.""" session_entity_types_client = dialogflow.SessionEntityTypesClient() session_entity_type_name = ( session_entity_types_client.session_entity_type_path( project_id, session_id, entity_type_display_name)) session_entity_types_client.delete_session_entity_type( session_entity_type_name)
def list_session_entity_types(project_id, session_id): session_entity_types_client = dialogflow.SessionEntityTypesClient() session_path = session_entity_types_client.session_path( project_id, session_id) session_entity_types = ( session_entity_types_client.list_session_entity_types(session_path)) print('SessionEntityTypes for session {}:\n'.format(session_path)) for session_entity_type in session_entity_types: print('\tSessionEntityType name: {}'.format(session_entity_type.name)) print('\tNumber of entities: {}\n'.format( len(session_entity_type.entities)))