NLU Certified Workshop

Topics:

Congratulations, you've made it to the Advanced Section! 

This is a Bonus section that designed to help you get familiar with Dialogflow's advanced features and capabilities. Since these features are advanced, they require some coding. 

Level 1 NLU Certification Students, are not expected to be proficient in using advanced features like Web-hooks, however you are expected to be familiar with them. NLU Certification Application details are at bottom of this page.

1. Prompts & Advanced UI

2. Fulfillment

 

By default, your agent responds to a matched intent with a static response. If you're using one of the integration options, you can provide a more dynamic response by using fulfillment. When you enable fulfillment for an intent, Dialogflow responds to that intent by calling a service that you define. For example, if an end-user wants to schedule a haircut on Friday, your service can check your database and respond to the end-user with availability information for Friday.

Each intent has a setting to enable fulfillment. If an intent requires some action by your system or a dynamic response, you should enable fulfillment for the intent. If an intent without fulfillment enabled is matched, Dialogflow uses the static response you defined for the intent.

When an intent with fulfillment enabled is matched, Dialogflow sends a request to your webhook service with information about the matched intent. Your system can perform any required actions and respond to Dialogflow with information for how to proceed. 

 

  1. The end-user types or speaks an expression.

  2. Dialogflow matches the end-user expression to an intent and extracts parameters.

  3. Dialogflow sends a webhook request message to your webhook service. This message contains information about the matched intent, the action, the parameters, and the response defined for the intent.

  4. Your service performs actions as needed, like database queries or external API calls.

  5. Your service sends a webhook response message to Dialogflow. This message contains the response that should be sent to the end-user.

  6. Dialogflow sends the response to the end-user.

  7. The end-user sees or hears the response.

Personalized Events

3. Events

Intents are normally matched when an end-user expression matches an intent training phrase. However, you can also trigger intents using events. Events can be invoked in many ways.

There are two types of events:

  • Platform events: These built-in events are provided by platform integrations. They are invoked when platform-specific events occur. For example, the FACEBOOK_LOCATION event is invoked by the Facebook integration when an end-user accepts or rejects a request for the end-user's location.

  • Custom events: These are events that you define. You can invoke these events using either fulfillment or the API. For example, you might set a timed alert during a conversation, which invokes an event at a certain time. This event could trigger an intent that alerts the end-user about something.

 

Configure an intent for events

Events are identified simply by their name. Platform-specific events have specific names, but you can name custom events anything.

To configure an intent so that it is triggered when certain events are invoked:

  1. Go to the Dialogflow ES Console.

  2. Select an agent.

  3. Select Intents in the left sidebar menu.

  4. Select an intent.

  5. Expand the Events section.

  6. Enter one or more event names.

To update intent events with the API, see the Intents type.

Event parameters

When invoked, events may also have parameter data that you can access in the triggered intent's responses. For more information, see Parameter reference for an event parameter.

Event Triggers

4. Connecting to Live Chat

5. Multi-Language Set Up

6. Webhooks

Webhook request

When an intent configured for fulfillment is matched, Dialogflow sends an HTTPS POST webhook request to your webhook service. The body of this request is a JSON object with information about the matched intent.

In addition to the end-user query, many integrations also send some information about the end-user as well.

 

For example, an ID to uniquely identify the user. This information can be accessed via the originalDetectIntentRequest field in the webhook request, which will contain the information sent from the integration platform.

See the WebhookRequest reference documentation for details.

Here is a sample request:

{

"responseId": "response-id",

"session": "projects/project-id/agent/sessions/session-id",

"queryResult": { "queryText": "End-user expression",

"parameters": { "param-name": "param-value"

},

"allRequiredParamsPresent": true,

"fulfillmentText": "Response configured for matched intent",

"fulfillmentMessages": [

{ "text":

{ "text":

[ "Response configured for matched intent" ]

}

}

],

"outputContexts": [

{

"name": "projects/project-id/agent/sessions/session-id/contexts/context-name",

"lifespanCount": 5,

"parameters": { "param-name": "param-value"

}

}

],

"intent": {

"name": "projects/project-id/agent/intents/intent-id",

"displayName": "matched-intent-name"

},

"intentDetectionConfidence": 1,

"diagnosticInfo": {},

"languageCode": "en"

}, "originalDetectIntentRequest": {}

}

Webhook response

Once your webhook receives a webhook request, it needs to send a webhook response. The body of this response is a JSON object with the following information:

 

The following limitations apply to your response:

  • The response must occur within 10 seconds for Google Assistant applications or 5 seconds for all other applications, otherwise the request will time out.

  • The response must be less than or equal to 64 KiB in size.

 

See the WebhookResponse reference documentation for details.

 

Text response

Example for a text response:

{

"fulfillmentMessages": [

{ "text":

{ "text": [

"Text response from webhook"

]

}

}

]

}

 

Card response

Example for a card response:

{

"fulfillmentMessages": [

{ "card": {

"title": "card title",

"subtitle": "card text",

"imageUri": "https://example.com/images/example.png",

"buttons": [

{

"text": "button text",

"postback": "https://example.com/path/for/end-user/to/follow"

}

]

}

}

]

}

 

Google Assistant response

Example for a Google Assistant response:

{

"payload":

{ "google":

{ "expectUserResponse": true,

"richResponse": {

"items": [ {

"simpleResponse": {

"textToSpeech":

"this is a Google Assistant response"

}

}

]

}

}

}

}

 

Context

Example that sets output context:

{

"fulfillmentMessages": [

{

"text": {

"text": [

"Text response from webhook"

]

}

}

],

"outputContexts": [

{

"name": "projects/project-id/agent/sessions/session-id/contexts/context-name",

"lifespanCount": 5,

"parameters": {

"param-name": "param-value"

}

}

]

}

 

Event

Example that invokes a custom event:

{

"followupEventInput": {

"name": "event-name",

"languageCode": "en-US",

"parameters": {

"param-name": "param-value"

}

}

}

 

Session entity

Example that sets a session entity:

{

"fulfillmentMessages": [

{

"text": {

"text": [

"Choose apple or orange"

]

}

}

],

"sessionEntityTypes":[

{

"name":"projects/project-id/agent/sessions/session-id/entityTypes/fruit",

"entities":[

{

"value":"APPLE_KEY",

"synonyms":

[

"apple",

"green apple",

"crabapple"

]

},

{

"value":"ORANGE_KEY",

"synonyms": [

"orange" ]

}

],

"entityOverrideMode":"ENTITY_OVERRIDE_MODE_OVERRIDE"

}

]

}

 

Enable and manage fulfillment

To enable and manage fulfillment for your agent with the console:

  1. Go to the Dialogflow ES Console.

  2. Select an agent.

  3. Select Fulfillment in the left sidebar menu.

  4. Toggle the Webhook field to Enabled.

  5. Provide the details for your webhook service in the form. If your webhook doesn't require authentication, leave the authentication fields blank.

  6. Click Save at the bottom of the page.

 

To enable and manage fulfillment for your agent with the API, see the agent reference. The getFulfillment and updateFulfillment methods can be used to manage fulfillment settings.

To enable fulfillment for an intent with the console:

  1. Select Intents in the left sidebar menu.

  2. Select an intent.

  3. Scroll down to the Fulfillment section.

  4. Toggle Enable webhook call for this intent to on.

  5. Click Save.

To enable fulfillment for an intent with the API, see the intents reference. Set the webhookState field to WEBHOOK_STATE_ENABLED.

 

Webhook for slot filling

When an intent is matched at runtime, the Dialogflow agent continues collecting information from the end-user until the end-user has provided data for each of the required parameters. This process is called slot filling.

By default, Dialogflow does not send a fulfillment webhook request until it has collected all required data from the end-user.

If webhook for slot filling is enabled, Dialogflow sends a fulfillment webhook request for each conversational turn during slot filling.

While in most cases, the parameter prompts are enough to collect all required parameters, a webhook for slot-filling allows you to define more specific agent logic during collection of the parameters. For example, your webhook could handle the customization of follow-up questions or setting parameter slots that cannot be retrieved from the end-user response, like from a database.

Enable webhook for slot filling

To enable webhook for slot filling at design-time:

  1. Go to the Dialogflow ES Console.

  2. Select an agent.

  3. Select Intents in the left sidebar menu.

  4. Select an intent.

  5. Scroll down to the Fulfillment section.

  6. Toggle Enable webhook call for slot filling on.

  7. Click Save.

 

Handle webhook for slot filling calls at runtime

The webhook request message received by your webhook service has a queryResult.parameters field. This field contains the current set of parameters provided by the end-user. Values that have not been collected yet are set to empty strings.

An example of the webhook response message for setting parameters can be found in Webhook Response examples.

:

Webhooks

7. Debugging, Training & Validation

8. Dialogflow CX

9. Live Q&A

 
 
 
 
 
 
 
 
 
 
gtag('config', 'AW-991893026')