Fulfillments

For an agent's conversational turn, the agent must respond to the end-user with an answer to a question, a query for information, or session termination. Your agent may also need to contact your service to generate dynamic responses or take actions for a turn. Fulfillment is used to accomplish all of this.

A fulfillment may contain any of the following:

  • Static response messages.
  • Webhook calls for dynamic responses and/or to take actions.
  • Parameter presets to set or override parameter values.

During an agent's turn, it is possible (and sometimes desirable) to call multiple fulfillments, each of which may generate a response message. Dialogflow maintains these responses in a response queue. Once the agent's turn is over, Dialogflow sends the ordered responses to the end-user.

ES fulfillment is limited to connecting a webhook service. The scope of fulfillment has been increased for CX, so it now covers all types of prompts and responses.

Fulfillment use cases

Fulfillment is used everywhere that a response message is needed:

For each of these use cases, the console will open a fulfillment editing panel.

Fulfillment screenshot

Static response messages (dialogue options)

Static response messages are agent responses that you define at design-time. You define them when creating fulfillment. At runtime, these responses are added to the response queue.

There are several types of response messages, which are described in subsections below. When using the console, a fulfillment panel has an initial text response message card, but you can click Add dialogue option to add more cards for other response message types.

Text

Text response messages send text dialog to the end-user. If your detect intent API calls or integration calls use speech synthesis, this text will be used to generate audio content. In this case, supplied text can optionally use the Speech Synthesis Markup Language (SSML).

You can define multiple text response cards, and multiple text responses within each card. If you define multiple cards, they are concatenated for a single response at runtime. If you define multiple responses within a card, one of the messages in the card is chosen at random at runtime.

These text messages can contain parameter references and inline system functions.

Custom payload

Some integrations support a custom payload response to handle rich responses. These custom payloads are supplied in a JSON format defined in the integration's documentation. For example, see the Dialogflow Messenger custom payload format.

You can include parameter references in your custom payload JSON. They should be treated as JSON string values, so wrap them in double quotes. For example:

{
  "someField": "$session.params.date"
}

You can also send a custom payload to integrations that you develop. It won't be processed by Dialogflow, so you need to handle it in your own business logic.

Live agent handoff

This response signals to the detect intent API caller that the conversation should be handed off to a human agent. Dialogflow only uses this signal to identify conversations that are handed off for measurement purposes, and it does not alter the session state in any way. Your system or integration can use this signal to take whatever actions are necessary to hand off the conversation. Dialogflow doesn't impose any structure on this data, so you can choose any structure that suits your system.

Conversation success metadata

This response signals to the detect intent API caller that the conversation with the Dialogflow agent succeeded. Dialogflow only uses this signal to identify conversations that succeeded for measurement purposes, and it does not alter the session state in any way. Your system or integration can use this signal to take whatever actions are necessary. Dialogflow doesn't impose any structure on this data, so you can choose any structure that suits your system.

Play pre-recorded audio

This response plays an audio file for integrations that support this feature. You must supply a publicly available URL to an audio file. For example, you can host a public file with Cloud Storage.

Output audio text

This response is similar to the text response, however it is only applicable to speech synthesis. If your agent can handle both text and voice sessions, you can use unique text and output audio text responses to create a different user experience for text versus voice. If output audio text is supplied for a voice session, the plain text responses are ignored.

If your agent handles both text and voice sessions, and you desire the same response messages, just use text responses for both text and voice sessions.

Output audio text is concatenated similar to text responses. If the output audio text responses are a mixture of text and SSML, the concatenated result is treated as SSML. The agent designer should ideally use either text or SSML consistently.

Conditional response

This response type is used for conditional responses. The general format is:

if [condition]
  [response]
elif [condition]
  [response]
elif [condition]
  [response]
else
  [response]
endif

where:

  • [condition] is the same format that is used for route conditions
  • [response] is a text response
  • elif and else blocks are optional

For example:

if $session.params.user-age >= 21
  Ok, you may enter.
else
  Sorry, you cannot enter.
endif

Both [condition] and [response] can use inline system functions to generate dynamic values during conversations. For more information, please check the references of system functions and route conditions.

For multilingual agents, [condition] is common for all languages, while [response] is language-specific. When you change [condition] for one language in the console, this part is updated in all agent's languages, and, since it becomes a new condition, [response] is cleared for all languages other than the language you selected when updating [condition].

Telephony transfer call

For some telephony integrations, you can specify a US phone number for call transfer. At runtime, when the Dialogflow virtual agent calls a fulfillment with call transfer, the call is transferred to the specified number and virtual agent handling is suspended.

Webhook calls

When a fulfillment is called, and the fulfillment has a webhook, the agent sends a request to your webhook. Your webhook can take any actions necessary within your service, provide a dynamic response message, override parameter values, and change the current page.

Parameter presets

You can use a fulfillment to provide presets that set or override current parameter values. These presets will be applied before resolving static response messages or calling a webhook.

You can also use system functions to preset the parameter to a dynamically generated value.

Some examples include:

  • Setting a parameter now to the current time:
    Parameter Value
    now $sys.func.NOW()
  • Incrementing an existing parameter counter by 1:
    Parameter Value
    counter $sys.func.ADD($session.params.counter, 1)

Advanced speech settings

These speech settings can optionally override the same page speech settings, flow speech settings, and agent speech settings.

Response queue

During an agent's turn, it is possible (and sometimes desirable) to call multiple fulfillments, each of which may generate a response message. Dialogflow maintains these responses in a response queue.

Partial response for streaming API

By default, Dialogflow only sends the ordered responses to the end-user once the agent's turn is over. You can also enable the Return partial response option in fulfillment to return currently queued responses as a partial response when using the streaming APIs. See Lifecycle of a page for more details.

For example, if your webhook will likely run for a long time, you can add a static response in the fulfillment and enable partial response. This makes Dialogflow flush the response queue and send all messages as a partial response before calling the webhook.

To test this feature in the simulator, you also need to turn on partial response.

Simulator partial response screenshot

In the following example, consider that your webhook takes 5 seconds to complete, and you don't enable partial response. The Dialogflow agent's conversational turn is not over until the webhook completes. During this 5 second turn, responses are queued while waiting for the webhook, and they are not returned to the end-user until the turn is complete. This leads to a bad user experience.

Without partial response.

If you enable partial response in the first fulfillment, Dialogflow returns the first fulfillment message quickly and calls the webhook. After the webhook is completed, Dialogflow returns the final response. The end-user experience is improved in this scenario, because they are told to expect a short wait. In addition, the webhook call is executing concurrently with a response being sent to the end-user.

With partial response.