Exemplo n.º 1
0
def sample_list_messages():
    # Create a client
    client = dialogflow_v2beta1.ConversationsClient()

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

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

    # Handle the response
    for response in page_result:
        print(response)
Exemplo n.º 2
0
def sample_complete_conversation():
    # Create a client
    client = dialogflow_v2beta1.ConversationsClient()

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

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

    # Handle the response
    print(response)
def complete_conversation(project_id, conversation_id):
    """Completes the specified conversation. Finished conversations are purged from the database after 30 days.

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

    client = dialogflow.ConversationsClient()
    conversation_path = client.conversation_path(project_id, conversation_id)
    conversation = client.complete_conversation(name=conversation_path)
    print("Completed Conversation.")
    print("Life Cycle State: {}".format(conversation.lifecycle_state))
    print("Conversation Profile Name: {}".format(
        conversation.conversation_profile))
    print("Name: {}".format(conversation.name))
    return conversation
def get_conversation(project_id, conversation_id):
    """Gets a specific conversation profile.

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

    client = dialogflow.ConversationsClient()
    conversation_path = client.conversation_path(project_id, conversation_id)

    response = client.get_conversation(name=conversation_path)

    print("Life Cycle State: {}".format(response.lifecycle_state))
    print("Conversation Profile Name: {}".format(
        response.conversation_profile))
    print("Name: {}".format(response.name))
    return response
def sample_create_conversation():
    # Create a client
    client = dialogflow_v2beta1.ConversationsClient()

    # Initialize request argument(s)
    conversation = dialogflow_v2beta1.Conversation()
    conversation.conversation_profile = "conversation_profile_value"

    request = dialogflow_v2beta1.CreateConversationRequest(
        parent="parent_value",
        conversation=conversation,
    )

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

    # Handle the response
    print(response)
Exemplo n.º 6
0
def sample_batch_create_messages():
    # Create a client
    client = dialogflow_v2beta1.ConversationsClient()

    # Initialize request argument(s)
    requests = dialogflow_v2beta1.CreateMessageRequest()
    requests.parent = "parent_value"
    requests.message.content = "content_value"

    request = dialogflow_v2beta1.BatchCreateMessagesRequest(
        parent="parent_value",
        requests=requests,
    )

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

    # 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