Ejemplo n.º 1
0
def sample_delete_conversation_profile():
    # Create a client
    client = dialogflow_v2beta1.ConversationProfilesClient()

    # Initialize request argument(s)
    request = dialogflow_v2beta1.DeleteConversationProfileRequest(
        name="name_value", )

    # Make the request
    client.delete_conversation_profile(request=request)
def list_conversation_profiles(project_id):
    """Lists the conversation profiles belonging to a project.

    Args: project_id: The GCP project linked with the conversation profile."""

    client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)
    response = client.list_conversation_profiles(parent=project_path)
    for conversation_profile in response:
        print("Display Name: {}".format(conversation_profile.display_name))
        print("Name: {}".format(conversation_profile.name))
    return response
def create_conversation_profile_smart_reply(project_id, display_name,
                                            smart_reply_allowlist_name,
                                            smart_reply_model_name):
    """Creates a conversation profile with given values for smart reply

    Args: project_id:  The GCP project linked with the conversation profile.
        display_name: The display name for the conversation profile to be
        created.
        smart_reply_allowlist_name: document name for smart reply allowlist.
        smart_reply_model_name: conversation model name for smart reply."""

    client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)

    conversation_profile = {
        "display_name": display_name,
        "human_agent_assistant_config": {
            "human_agent_suggestion_config": {
                "feature_configs": []
            }
        },
        "language_code": "en-US",
    }
    feature_config = {
        "suggestion_feature": {
            "type_": "SMART_REPLY"
        },
        "suggestion_trigger_settings": {
            "no_small_talk": True,
            "only_end_user": True,
        },
        "query_config": {
            "document_query_source": {
                "documents": [smart_reply_allowlist_name]
            },
            "max_results": 3,
        },
        "conversation_model_config": {
            "model": smart_reply_model_name
        },
    }
    conversation_profile["human_agent_assistant_config"][
        "human_agent_suggestion_config"]["feature_configs"].append(
            feature_config)

    response = client.create_conversation_profile(
        parent=project_path, conversation_profile=conversation_profile)

    print("Conversation Profile created:")
    print("Display Name: {}".format(response.display_name))
    # Put Name is the last to make it easier to retrieve.
    print("Name: {}".format(response.name))
    return response
Ejemplo n.º 4
0
def create_conversation_profile_smart_reply(project_id, display_name,
                                            smart_reply_allowlist_name,
                                            smart_reply_model_name):
    """Creates a conversation profile with given values for smart reply

    Args: project_id:  The GCP project linked with the conversation profile.
        display_name: The display name for the conversation profile to be
        created.
        smart_reply_allowlist_name: document name for smart reply allowlist.
        smart_reply_model_name: conversation model name for smart reply."""

    client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)

    conversation_profile = {
        'display_name': display_name,
        'human_agent_assistant_config': {
            'human_agent_suggestion_config': {
                'feature_configs': []
            }
        },
        'language_code': 'en-US'
    }
    feature_config = {
        'suggestion_feature': {
            'type_': 'SMART_REPLY'
        },
        'suggestion_trigger_settings': {
            'no_small_talk': True,
            'only_end_user': True,
        },
        'query_config': {
            'document_query_source': {
                'documents': [smart_reply_allowlist_name]
            },
            'max_results': 3
        },
        'conversation_model_config': {
            'model': smart_reply_model_name
        }
    }
    conversation_profile['human_agent_assistant_config'][
        'human_agent_suggestion_config']['feature_configs'].append(
            feature_config)

    response = client.create_conversation_profile(
        parent=project_path, conversation_profile=conversation_profile)

    print('Conversation Profile created:')
    print('Display Name: {}'.format(response.display_name))
    # Put Name is the last to make it easier to retrieve.
    print('Name: {}'.format(response.name))
    return response
def sample_get_conversation_profile():
    # Create a client
    client = dialogflow_v2beta1.ConversationProfilesClient()

    # Initialize request argument(s)
    request = dialogflow_v2beta1.GetConversationProfileRequest(
        name="name_value", )

    # Make the request
    response = client.get_conversation_profile(request=request)

    # Handle the response
    print(response)
def delete_conversation_profile(project_id, conversation_profile_id):
    """Deletes a specific conversation profile.

    Args: project_id: The GCP project linked with the conversation profile.
        conversation_profile_id: Id of the conversation profile."""

    client = dialogflow.ConversationProfilesClient()
    conversation_profile_path = client.conversation_profile_path(
        project_id, conversation_profile_id)

    client.delete_conversation_profile(name=conversation_profile_path)

    print("Conversation Profile deleted.")
Ejemplo n.º 7
0
def sample_list_conversation_profiles():
    # Create a client
    client = dialogflow_v2beta1.ConversationProfilesClient()

    # Initialize request argument(s)
    request = dialogflow_v2beta1.ListConversationProfilesRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_conversation_profiles(request=request)

    # Handle the response
    for response in page_result:
        print(response)
Ejemplo n.º 8
0
def sample_update_conversation_profile():
    # Create a client
    client = dialogflow_v2beta1.ConversationProfilesClient()

    # Initialize request argument(s)
    conversation_profile = dialogflow_v2beta1.ConversationProfile()
    conversation_profile.display_name = "display_name_value"

    request = dialogflow_v2beta1.UpdateConversationProfileRequest(
        conversation_profile=conversation_profile, )

    # Make the request
    response = client.update_conversation_profile(request=request)

    # Handle the response
    print(response)
def get_conversation_profile(project_id, conversation_profile_id):
    """Gets a specific conversation profile.

    Args: project_id: The GCP project linked with the conversation profile.
        conversation_profile_id: Id of the conversation profile."""

    client = dialogflow.ConversationProfilesClient()
    conversation_profile_path = client.conversation_profile_path(
        project_id, conversation_profile_id)

    response = client.get_conversation_profile(name=conversation_profile_path)

    print("Got conversation profile:")
    print("Display Name: {}".format(response.display_name))
    print("Name: {}".format(response.name))
    return response
Ejemplo n.º 10
0
def sample_set_suggestion_feature_config():
    # Create a client
    client = dialogflow_v2beta1.ConversationProfilesClient()

    # Initialize request argument(s)
    request = dialogflow_v2beta1.SetSuggestionFeatureConfigRequest(
        conversation_profile="conversation_profile_value",
        participant_role="END_USER",
    )

    # Make the request
    operation = client.set_suggestion_feature_config(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)
def create_conversation(project_id, conversation_profile_id):
    """Creates a conversation with given values

    Args:
        project_id:  The GCP project linked with the conversation.
        conversation_profile_id: The conversation profile id used to create
        conversation."""

    client = dialogflow.ConversationsClient()
    conversation_profile_client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)
    conversation_profile_path = conversation_profile_client.conversation_profile_path(
        project_id, conversation_profile_id)
    conversation = {"conversation_profile": conversation_profile_path}
    response = client.create_conversation(parent=project_path,
                                          conversation=conversation)

    print("Life Cycle State: {}".format(response.lifecycle_state))
    print("Conversation Profile Name: {}".format(
        response.conversation_profile))
    print("Name: {}".format(response.name))
    return response
def create_conversation_profile_article_faq(
    project_id,
    display_name,
    article_suggestion_knowledge_base_id=None,
    faq_knowledge_base_id=None,
):
    """Creates a conversation profile with given values

    Args: project_id:  The GCP project linked with the conversation profile.
        display_name: The display name for the conversation profile to be
        created.
        article_suggestion_knowledge_base_id: knowledge base id for article
        suggestion.
        faq_knowledge_base_id: knowledge base id for faq."""

    client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)

    conversation_profile = {
        "display_name": display_name,
        "human_agent_assistant_config": {
            "human_agent_suggestion_config": {
                "feature_configs": []
            }
        },
        "language_code": "en-US",
    }

    if article_suggestion_knowledge_base_id is not None:
        as_kb_path = dialogflow.KnowledgeBasesClient.knowledge_base_path(
            project_id, article_suggestion_knowledge_base_id)
        feature_config = {
            "suggestion_feature": {
                "type_": "ARTICLE_SUGGESTION"
            },
            "suggestion_trigger_settings": {
                "no_small_talk": True,
                "only_end_user": True,
            },
            "query_config": {
                "knowledge_base_query_source": {
                    "knowledge_bases": [as_kb_path]
                },
                "max_results": 3,
            },
        }
        conversation_profile["human_agent_assistant_config"][
            "human_agent_suggestion_config"]["feature_configs"].append(
                feature_config)
    if faq_knowledge_base_id is not None:
        faq_kb_path = dialogflow.KnowledgeBasesClient.knowledge_base_path(
            project_id, faq_knowledge_base_id)
        feature_config = {
            "suggestion_feature": {
                "type_": "FAQ"
            },
            "suggestion_trigger_settings": {
                "no_small_talk": True,
                "only_end_user": True,
            },
            "query_config": {
                "knowledge_base_query_source": {
                    "knowledge_bases": [faq_kb_path]
                },
                "max_results": 3,
            },
        }
        conversation_profile["human_agent_assistant_config"][
            "human_agent_suggestion_config"]["feature_configs"].append(
                feature_config)

    response = client.create_conversation_profile(
        parent=project_path, conversation_profile=conversation_profile)

    print("Conversation Profile created:")
    print("Display Name: {}".format(response.display_name))
    # Put Name is the last to make it easier to retrieve.
    print("Name: {}".format(response.name))
    return response
Ejemplo n.º 13
0
def create_conversation_profile_article_faq(
        project_id,
        display_name,
        article_suggestion_knowledge_base_id=None,
        faq_knowledge_base_id=None):
    """Creates a conversation profile with given values

    Args: project_id:  The GCP project linked with the conversation profile.
        display_name: The display name for the conversation profile to be
        created.
        article_suggestion_knowledge_base_id: knowledge base id for article
        suggestion.
        faq_knowledge_base_id: knowledge base id for faq."""

    client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)

    conversation_profile = {
        'display_name': display_name,
        'human_agent_assistant_config': {
            'human_agent_suggestion_config': {
                'feature_configs': []
            }
        },
        'language_code': 'en-US'
    }

    if article_suggestion_knowledge_base_id is not None:
        as_kb_path = dialogflow.KnowledgeBasesClient.knowledge_base_path(
            project_id, article_suggestion_knowledge_base_id)
        feature_config = {
            'suggestion_feature': {
                'type_': 'ARTICLE_SUGGESTION'
            },
            'suggestion_trigger_settings': {
                'no_small_talk': True,
                'only_end_user': True,
            },
            'query_config': {
                'knowledge_base_query_source': {
                    'knowledge_bases': [as_kb_path]
                },
                'max_results': 3
            },
        }
        conversation_profile['human_agent_assistant_config'][
            'human_agent_suggestion_config']['feature_configs'].append(
                feature_config)
    if faq_knowledge_base_id is not None:
        faq_kb_path = dialogflow.KnowledgeBasesClient.knowledge_base_path(
            project_id, faq_knowledge_base_id)
        feature_config = {
            'suggestion_feature': {
                'type_': 'FAQ'
            },
            'suggestion_trigger_settings': {
                'no_small_talk': True,
                'only_end_user': True,
            },
            'query_config': {
                'knowledge_base_query_source': {
                    'knowledge_bases': [faq_kb_path]
                },
                'max_results': 3
            },
        }
        conversation_profile['human_agent_assistant_config'][
            'human_agent_suggestion_config']['feature_configs'].append(
                feature_config)

    response = client.create_conversation_profile(
        parent=project_path, conversation_profile=conversation_profile)

    print('Conversation Profile created:')
    print('Display Name: {}'.format(response.display_name))
    # Put Name is the last to make it easier to retrieve.
    print('Name: {}'.format(response.name))
    return response