Try the new Conversation API Playground to learn more about using our API!

Conversation Webhook Format

This section describes the format of the JSON payload when Actions on Google invokes your fulfillment through the Actions SDK.

Once a conversation starts, it's identified by a unique conversationId. For each subsequent user query to the Assistant, your fulfillment receives an intent that your webhook must process and respond to. This conversationIdis persisted in every request and response pair until the conversation ends.

Request body

When users make an initial query or provide some subsequent input, the Assistant sends a request to your fulfillment. Conversation webhook requests from the Assistant contain data such as the intent that was triggered, the raw text of the user input, and the surface capabilities of the user's device.

The key fields for a request in the conversation webhook format are summarized below:

Field Description
isInSandbox This boolean variable is primarily used to for the transactions feature, to indicate whether your webhook should handle this request in sandbox mode. In sandbox mode, your webhook should not charge or fulfill any purchase orders by users. By default, it is set to "true".
surface Information about the Assistant surface the user is interacting with and its capabilities.
Inputs Information about the invocation request. For the triggering invocation, this includes an intent] that maps to an action. For subsequent requests in a conversation, this object might also include arguments corresponding to the expected inputs specified by your fulfillment.
User Information about the user who initiated the request. This information includes permissions granted by the user, and the user's locale.
Conversation Information about the conversation context, including the conversation ID, the type (for example, whether this request is initiating a new conversation), and a conversation token to store persistent data across the conversation lifespan.
availableSurfaces This information is used for multi-surface conversations.

Simple invocation request example

The snippet below shows an example of a invocation request in the conversation webhook format.

{
  "user": {
    "userId": "ABwppHEFc0F4IkvC3ZbDczpcInyAp8a4gozs2DU4z-7198fZvFGtlpFI73uMNZvbt3ChVBj-nusdCplX4SeNAhIf0g",
    "locale": "en-US",
    "lastSeen": "2018-03-21T17:59:52Z",
    "userStorage": "{\"data\":{}}"
  },
  "conversation": {
    "conversationId": "1521784527171",
    "type": "NEW"
  },
  "inputs": [
    {
      "intent": "actions.intent.MAIN",
      "rawInputs": [
        {
          "inputType": "VOICE",
          "query": "Talk to my test app"
        }
      ]
    }
  ],
  "surface": {
    "capabilities": [
      {
        "name": "actions.capability.SCREEN_OUTPUT"
      },
      {
        "name": "actions.capability.AUDIO_OUTPUT"
      },
      {
        "name": "actions.capability.WEB_BROWSER"
      },
      {
        "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
      }
    ]
  },
  "isInSandbox": true,
  "availableSurfaces": [
    {
      "capabilities": [
        {
          "name": "actions.capability.SCREEN_OUTPUT"
        },
        {
          "name": "actions.capability.AUDIO_OUTPUT"
        }
      ]
    }
  ]
}

Simple conversation request example

The snippet below shows an example of a conversational request in the conversation webhook format, where the user input is a text string (for example, “My lucky number is 88.”):

{
  "user": {
    "userId": "ABwppHFrGYSS7ABErz0C5IcxhyqzlpDxLAKjDiBPggL-Oii0eKeDZ3iFiAc9yiJDY6bWr6K8mYLM77GA8DnZUyGJ6Ok",
    "locale": "en-US",
    "lastSeen": "2018-03-21T21:02:13Z",
    "userStorage": "{\"data\":{}}"
  },
  "conversation": {
    "conversationId": "1524602877583",
    "type": "ACTIVE",
    "conversationToken": "[]"
  },
  "inputs": [
    {
      "intent": "actions.intent.TEXT",
      "rawInputs": [
        {
          "inputType": "KEYBOARD",
          "query": "My lucky number is 88."
        }
      ],
      "arguments": [
        {
          "name": "text",
          "rawText": "My lucky number is 88.",
          "textValue": "My lucky number is 88."
        }
      ]
    }
  ],
  "surface": {
    "capabilities": [
      {
        "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
      },
      {
        "name": "actions.capability.WEB_BROWSER"
      },
      {
        "name": "actions.capability.AUDIO_OUTPUT"
      },
      {
        "name": "actions.capability.SCREEN_OUTPUT"
      }
    ]
  },
  "isInSandbox": true,
  "availableSurfaces": [
    {
      "capabilities": [
        {
          "name": "actions.capability.AUDIO_OUTPUT"
        },
        {
          "name": "actions.capability.SCREEN_OUTPUT"
        }
      ]
    }
  ]
}

Response body

The Content-Type in the header of HTTP posts from your fulfillment endpoint to the Assistant must be application/json.

A response in the conversation webhook format contains data such as the actual UI to show the user (including audio and visual components), and the intent that can be triggered in the subsequent request (called an expected intent). The expected intent can be any of the intents that the Assistant understands, as described in the Intents API reference.

To learn more about formatting the user interface for your responses when they're displayed in the Assistant, see the Responses documentation.

Simple response example

The snippet below shows an example of a simple response in the conversation webhook format.

{
  "conversationToken": "{\"state\":null,\"data\":{}}",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "initialPrompts": [
          {
            "ssml": "<speak>Hello! <break time=\"1\"/> You are using the Actions SDK.Do you want to hear more about it?"
          }
        ],
        "noInputPrompts": [
          {
            "ssml": "I didn't hear that."
          },
          {
            "ssml": "If you're still there, say that again."
          },
          {
            "ssml": "We can stop here. See you soon."
          }
        ]
      },
      "possibleIntents": [
        {
          "intent": "actions.intent.TEXT"
        }
      ]
    }
  ]
}

Helper example

The snippet below shows an example of using a helper intent in the conversation webhook format. In this example, the webhook is using the actions.intent.OPTIONS helper intent to instruct the Assistant to obtain a user selection between multiple options.

To learn more about using helper intents, see the Helpers guide.

{
  "conversationToken": "{\"state\":null,\"data\":{}}",
  "expectUserResponse": true,
  "expectedInputs": [
    {
      "inputPrompt": {
        "richInitialPrompt": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "This is a simple response for a carousel"
              }
            }
          ],
          "suggestions": [
            {
              "title": "Basic Card"
            },
            {
              "title": "List"
            },
            {
              "title": "Carousel"
            },
            {
              "title": "Suggestions"
            }
          ]
        }
      },
      "possibleIntents": [
        {
          "intent": "actions.intent.OPTION",
          "inputValueData": {
            "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
            "carouselSelect": {
              "items": [
                {
                  "optionInfo": {
                    "key": "title",
                    "synonyms": [
                      "synonym of title 1",
                      "synonym of title 2",
                      "synonym of title 3"
                    ]
                  },
                  "title": "Title of First List Item",
                  "description": "This is a description of a carousel item",
                  "image": {
                    "url": "/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
                    "accessibilityText": "Image alternate text"
                  }
                },
                {
                  "optionInfo": {
                    "key": "googleHome",
                    "synonyms": [
                      "Google Home Assistant",
                      "Assistant on the Google Home"
                    ]
                  },
                  "title": "Google Home",
                  "description": "Google Home is a voice-activated speaker powered by\n the Google Assistant.",
                  "image": {
                    "url": "https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw",
                    "accessibilityText": "Google Home"
                  }
                },
                {
                  "optionInfo": {
                    "key": "googlePixel",
                    "synonyms": [
                      "Google Pixel XL",
                      "Pixel",
                      "Pixel XL"
                    ]
                  },
                  "title": "Google Pixel",
                  "description": "Pixel. Phone by Google.",
                  "image": {
                    "url": "https://storage.googleapis.com/madebygoog/v1/Pixel/Pixel_ColorPicker/Pixel_Device_Angled_Black-720w.png",
                    "accessibilityText": "Google Pixel"
                  }
                },
                {
                  "optionInfo": {
                    "key": "googleAllo",
                    "synonyms": [
                      "Allo"
                    ]
                  },
                  "title": "Google Allo",
                  "description": "Introducing Google Allo, a smart messaging appthat helps you say more and do more.",
                  "image": {
                    "url": "https://allo.google.com/images/allo-logo.png",
                    "accessibilityText": "Google Allo Logo"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

End conversation example

The snippet below shows an example of a simple response to end a conversation session in the conversation webhook response format.

The expectedUserResponse value of false in the response message signals to the Assistant that no further user input is expected and that it should end the current conversation. The finalResponse value indicates what the Assistant should display or output to the user before the conversation ends.

{
  "conversationToken": "{\"state\":null,\"data\":{}}",
  "expectUserResponse": false,
  "finalResponse": {
    "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Goodbye and good luck!"
            }
          }
        ]
      }
  }
}

To learn how to override the default behavior when users invoke a standard phrase to end a conversation with the Assistant, see the App Exits guide.