Optionally, you can create a conversation between a Dialogflow virtual agent and an end-user. A virtual agent tries to resolve customer conversations on its own before escalating to a human agent. If you use Agent Assist without a virtual agent, end-users are sent straight to human agents without first interacting with virtual agents as an intermediate step.
Before you begin
- Read Dialogflow basics.
- Perform setup steps.
- Create an agent using either Dialogflow ES or Dialogflow CX. If you intend to test this virtual agent using the Agent Assist simulator, be aware that the virtual agent must be a Dialogflow ES agent and it must also be associated with the same GCP project you intend to use with the Agent Assist Console. If you do not intend to test your virtual agent using the simulator, the agent can be either an ES or a CX agent and can be associated with any GCP project.
Import the example file to your agent
The steps in this guide make assumptions about your agent, so you need to import an agent prepared for this guide. When importing, these steps use the restore option, which overwrites all agent settings, intents, and entities.
To import the file, follow these steps:
-
Download the
room-booking-agent.zip
file. - Go to the Dialogflow ES Console.
- Select your agent.
- Click the settings settings button next to the agent name.
- Select the Export and Import tab.
- Select Restore From Zip and follow instructions to restore the zip file that you downloaded.
Configure a Dialogflow agent
This section shows you how to create and configure a conversation profile. A conversation profile configures a set of parameters that control the suggestions made to an agent during a conversation.
Create a conversation profile
You must create a conversation profile before you can create a conversation. A conversation profile is used to configure agents and connected services for the conversation. The steps below use the API to create a conversation profile using the Dialogflow agent that we created in the steps above. As an alternative, you can use the Agent Assist Console to create conversation profiles.
REST
To create a conversation profile, call thecreate
method on the
ConversationProfile
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your GCP project ID
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversationProfiles
Request JSON body:
{ "displayName": "My Contact Center Solution", "automatedAgentConfig": { "agent": "projects/PROJECT_ID/agent/environments/-" } }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/conversationProfiles/CONVERSATION_PROFILE_ID", "displayName": "My Contact Center Solution", "automatedAgentConfig": { "agent": "projects/PROJECT_ID/agent/environments/-" } }
The path segment after conversationProfiles
contains your new conversation
profile ID.
Handling conversations at runtime
Create a conversation
When a dialog begins between an end-user and a human or virtual agent, you create a conversation. In order to see suggestions, you must also create an end-user participant and add it to the conversation. The following sections walk you through this process.
REST
To create a conversation, call thecreate
method on the
conversations
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Cloud project ID
- LOCATION_ID: your location ID
- CONVERSATION_PROFILE_ID: the ID you received when creating the conversation profile
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/conversations
Request JSON body:
{ "conversationProfile": "projects/PROJECT_ID/locations/LOCATION_ID/conversationProfiles/CONVERSATION_PROFILE_ID", }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID", "lifecycleState": "IN_PROGRESS", "conversationProfile": "projects/PROJECT_ID/locations/LOCATION_ID/conversationProfiles/CONVERSATION_PROFILE_ID", "startTime": "2018-11-05T21:05:45.622Z" }
The path segment after conversations
contains your new conversation ID.
Create a participant
Now you need to add a participant to the conversation. The end-user is the only participant you need to add to the conversation.
REST
To create a participant, call thecreate
method on the
participants
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Cloud project ID
- LOCATION_ID: your location ID
- CONVERSATION_ID: your conversation ID
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants
Request JSON body:
{ "role": "END_USER", }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID", "role": "END_USER" }
The path segment after participants
contains your new participant ID.
Analyze content and get automated responses
After you have created an end-user participant, you can send input from that end-user to the API. The API sends the input to a detect intent request and returns the response.
REST
To send text, call theanalyzeContent
method on the
participants
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your GCP project ID
- CONVERSATION_ID: your conversation ID
- PARTICIPANT_ID: your end-user participant ID
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID:analyzeContent
Request JSON body:
{ "textInput": { "text": "I want to book a room", "languageCode": "en-US" } }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "replyText": "I can help with that. Where would you like to reserve a room?", "automatedAgentReply": { "detectIntentResponse": { "responseId": "38e5d378-12e5-453b-9c37-ac6828b86673", "queryResult": { "queryText": "I want to book a room", "action": "room.reservation", "parameters": { "date": "", "duration": "", "guests": "", "location": "", "time": "" }, "fulfillmentText": "I can help with that. Where would you like to reserve a room?", "fulfillmentMessages": [ { "text": { "text": [ "I can help with that. Where would you like to reserve a room?" ] } } ], "intent": { "name": "projects/PROJECT_ID/agent/intents/e8f6a63e-73da-4a1a-8bfc-857183f71228", "displayName": "room.reservation" }, "intentDetectionConfidence": 0.8, "languageCode": "en-us" }, "webhookStatus": {} } } }
Complete the conversation
Once your conversation is finished, end it to make sure that it's marked as
done
. Completed conversations get cleaned up after a period of time.
REST
To end a conversation, call thecomplete
method on the
conversations
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: your GCP project ID
- CONVERSATION_ID: the ID you received when creating the conversation
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID:complete
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID", "lifecycleState": "COMPLETED", "conversationProfile": "projects/PROJECT_ID/conversationProfiles/CONVERSATION_PROFILE_ID", "startTime": "2018-11-05T21:05:45.622Z", "endTime": "2018-11-06T03:50:26.930Z" }