Build Fulfillment

The documentation here describes how to build fulfillment generally.
See Surface Capabilities and
Responses,
for more information on how to handle specific portions of your conversation.

Fulfillment defines the conversational interface for your Actions project to obtain
user input and the logic to process the input and eventually fulfill the Action.

Overview

Your fulfillment receives requests from the Assistant, processes the request and
responds. This back-and-forth request and response process drives the
conversation forward until you eventually fulfill the initial user request.

The following steps describe how you can build fulfillment using the Actions
SDK with the Node.js or the Java/Kotlin client library:

Ending conversations

When you no longer want any user input in return and want to end the conversation,
call the conv.close() function.
This function tells the Google Assistant to speak back the text to the user and end the conversation by closing the microphone.

Handling the main invocation intent

When users trigger the app.intent.action.MAIN intent, you normally don't
need to do any user input processing. If your action package contains many
actions and covers many use cases, it's a good idea to orient the user by telling
them a few things that they can do.

Call the conv.ask() function passing your response as an argument.
The Google Assistant speaks your response to the user and then
waits for the user to trigger one of the intents that you specified.

Conversation state

If you are using the conversation HTTP/JSON webhook API, you can maintain the
state of your conversations with a JSON formatted object (conversationToken)
that is passed back and forth between you and the Google Assistant. If you are
using the Node.js client library, you
can write to and read from the conv.data field directly. This field
is passed back and forth automatically between requests and responses.