Google Integration with REST API

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Integrate the REST API

There are two integration points as outlined below.

1. When Google posts to your webhook endpoint

When Google posts to your webhook endpoint, post the same data Google sent to you to the following endpoint:

https://tracker.dashbot.io/track?platform=google&v=10.1.1-rest&type=incoming&apiKey=API_KEY_HERE

The data to POST should pass the following data:

{
  "request_body": {
    "originalRequest": {
      "data": {
        "isInSandbox": true,
        "surface": {
          "capabilities": [
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            },
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            }
          ]
        },
        "user": {
          "locale": "en-US",
          "userId": "APhe68EDOxlex9HCuUj3gsZaWoZa"
        },
        "inputs": [
          {
            "rawInputs": [
              {
                "inputType": "KEYBOARD",
                "query": "talk to my test app"
              }
            ],
            "intent": "actions.intent.MAIN"
          }
        ],
        "conversation": {
          "type": "NEW",
          "conversationId": "1501533781539"
        }
      },
      "version": "2",
      "source": "google"
    },
    "result": {
      "actionIncomplete": false,
      "score": 1,
      "metadata": {
        "intentId": "abad66de-d382-4bf7-90e3-35f77ae83cc6",
        "webhookUsed": "true",
        "webhookForSlotFillingUsed": "false",
        "nluResponseTime": 1,
        "intentName": "Default Welcome Intent"
      },
      "resolvedQuery": "GOOGLE_ASSISTANT_WELCOME",
      "action": "input.welcome",
      "source": "agent",
      "contexts": [
        {
          "name": "google_assistant_welcome",
          "lifespan": 0
        },
        {
          "name": "actions_capability_screen_output",
          "lifespan": 0
        },
        {
          "name": "actions_capability_audio_output",
          "lifespan": 0
        },
        {
          "name": "google_assistant_input_type_keyboard",
          "lifespan": 0
        }
      ],
      "fulfillment": {
        "speech": "Hi!",
        "messages": [
          {
            "type": 0,
            "speech": "Hi!"
          }
        ]
      }
    },
    "id": "166fdebd-052f-4c08-85ef-ada758d8037f",
    "sessionId": "1501533781539",
    "lang": "en",
    "timestamp": "2017-07-31T20:43:01.572Z",
    "status": {
      "errorType": "success",
      "code": 200
    }
  }
}

Sample cURL

curl -X POST -H "Content-Type: application/json" \
     -d '{"request_body":{"originalRequest":{"data":{"isInSandbox":true,"surface":{"capabilities":[{"name":"actions.capability.AUDIO_OUTPUT"},{"name":"actions.capability.SCREEN_OUTPUT"}]},"user":{"locale":"en-US","userId":"APhe68EDOxlex9HCuUj3gsZaWoZa"},"inputs":[{"rawInputs":[{"inputType":"KEYBOARD","query":"talk to my test app"}],"intent":"actions.intent.MAIN"}],"conversation":{"type":"NEW","conversationId":"1501533781539"}},"version":"2","source":"google"},"result":{"actionIncomplete":false,"score":1,"metadata":{"intentId":"abad66de-d382-4bf7-90e3-35f77ae83cc6","webhookUsed":"true","webhookForSlotFillingUsed":"false","nluResponseTime":1,"intentName":"Default Welcome Intent"},"resolvedQuery":"GOOGLE_ASSISTANT_WELCOME","action":"input.welcome","source":"agent","contexts":[{"name":"google_assistant_welcome","lifespan":0},{"name":"actions_capability_screen_output","lifespan":0},{"name":"actions_capability_audio_output","lifespan":0},{"name":"google_assistant_input_type_keyboard","lifespan":0}],"fulfillment":{"speech":"Hi!","messages":[{"type":0,"speech":"Hi!"}]}},"id":"166fdebd-052f-4c08-85ef-ada758d8037f","sessionId":"1501533781539","lang":"en","timestamp":"2017-07-31T20:43:01.572Z","status":{"errorType":"success","code":200}}}' \
     'https://tracker.dashbot.io/track?platform=google&v=10.1.1-rest&type=incoming&apiKey=API_KEY_HERE'

2. When your bot sends a message

When your bot sends a message, POST to the following endpoint:

https://tracker.dashbot.io/track?platform=google&v=10.1.1-rest&type=outgoing&apiKey=API_KEY_HERE

The data to POST should pass the following data:

{
  "request_body": {
    "originalRequest": {
      "data": {
        "isInSandbox": true,
        "surface": {
          "capabilities": [
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            },
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            }
          ]
        },
        "user": {
          "locale": "en-US",
          "userId": "APhe68EDOxlex9HCuUj3gsZaWoZa"
        },
        "inputs": [
          {
            "rawInputs": [
              {
                "inputType": "KEYBOARD",
                "query": "talk to my test app"
              }
            ],
            "intent": "actions.intent.MAIN"
          }
        ],
        "conversation": {
          "type": "NEW",
          "conversationId": "1501533781539"
        }
      },
      "version": "2",
      "source": "google"
    },
    "result": {
      "actionIncomplete": false,
      "score": 1,
      "metadata": {
        "intentId": "abad66de-d382-4bf7-90e3-35f77ae83cc6",
        "webhookUsed": "true",
        "webhookForSlotFillingUsed": "false",
        "nluResponseTime": 1,
        "intentName": "Default Welcome Intent"
      },
      "resolvedQuery": "GOOGLE_ASSISTANT_WELCOME",
      "action": "input.welcome",
      "source": "agent",
      "contexts": [
        {
          "name": "google_assistant_welcome",
          "lifespan": 0
        },
        {
          "name": "actions_capability_screen_output",
          "lifespan": 0
        },
        {
          "name": "actions_capability_audio_output",
          "lifespan": 0
        },
        {
          "name": "google_assistant_input_type_keyboard",
          "lifespan": 0
        }
      ],
      "fulfillment": {
        "speech": "Hi!",
        "messages": [
          {
            "type": 0,
            "speech": "Hi!"
          }
        ]
      }
    },
    "id": "166fdebd-052f-4c08-85ef-ada758d8037f",
    "sessionId": "1501533781539",
    "lang": "en",
    "timestamp": "2017-07-31T20:43:01.572Z",
    "status": {
      "errorType": "success",
      "code": 200
    }
  },
  "message": {
    "data": {
      "google": {
        "expectUserResponse": true,
        "richResponse": {
          "items": [
            {
              "simpleResponse": {
                "textToSpeech": "Hello there! Let's chat. Ask me anything, or pat me, amuse me, or ask for help",
                "displayText": "Hello there! Let's chat..."
              }
            },
            {
              "basicCard": {
                "image": {
                  "accessibilityText": "welcome cat",
                  "url": "http://i.dashbot.io/cat/pepper-fb.png"
                },
                "formattedText": "Ask me anything, or pat me, amuse me, or ask for help"
              }
            }
          ],
          "suggestions": [
            {
              "title": "pat"
            },
            {
              "title": "amuse"
            },
            {
              "title": "help"
            }
          ]
        }
      }
    },
    "speech": "Hello there! Let's chat. Ask me anything, or pat me, amuse me, or ask for help",
    "contextOut": [
      {
        "name": "_actions_on_google_",
        "lifespan": 100
      }
    ]
  }
}

Sample cURL

curl -X POST -H "Content-Type: application/json" \
     -d '{"request_body":{"originalRequest":{"data":{"isInSandbox":true,"surface":{"capabilities":[{"name":"actions.capability.AUDIO_OUTPUT"},{"name":"actions.capability.SCREEN_OUTPUT"}]},"user":{"locale":"en-US","userId":"APhe68EDOxlex9HCuUj3gsZaWoZa"},"inputs":[{"rawInputs":[{"inputType":"KEYBOARD","query":"talk to my test app"}],"intent":"actions.intent.MAIN"}],"conversation":{"type":"NEW","conversationId":"1501533781539"}},"version":"2","source":"google"},"result":{"actionIncomplete":false,"score":1,"metadata":{"intentId":"abad66de-d382-4bf7-90e3-35f77ae83cc6","webhookUsed":"true","webhookForSlotFillingUsed":"false","nluResponseTime":1,"intentName":"Default Welcome Intent"},"resolvedQuery":"GOOGLE_ASSISTANT_WELCOME","action":"input.welcome","source":"agent","contexts":[{"name":"google_assistant_welcome","lifespan":0},{"name":"actions_capability_screen_output","lifespan":0},{"name":"actions_capability_audio_output","lifespan":0},{"name":"google_assistant_input_type_keyboard","lifespan":0}],"fulfillment":{"speech":"Hi!","messages":[{"type":0,"speech":"Hi!"}]}},"id":"166fdebd-052f-4c08-85ef-ada758d8037f","sessionId":"1501533781539","lang":"en","timestamp":"2017-07-31T20:43:01.572Z","status":{"errorType":"success","code":200}},"message":{"data":{"google":{"expectUserResponse":true,"richResponse":{"items":[{"simpleResponse":{"textToSpeech":"Hello there! Lets chat. Ask me anything, or pat me, amuse me, or ask for help","displayText":"Hello there! Let'"'"'s chat..."}},{"basicCard":{"image":{"accessibilityText":"welcome cat","url":"http://i.dashbot.io/cat/pepper-fb.png"},"formattedText":"Ask me anything, or pat me, amuse me, or ask for help"}}],"suggestions":[{"title":"pat"},{"title":"amuse"},{"title":"help"}]}}},"speech":"Hello there! Let'"'"'s chat. Ask me anything, or pat me, amuse me, or ask for help","contextOut":[{"name":"_actions_on_google_","lifespan":100}]}}' \
     'https://tracker.dashbot.io/track?platform=google&v=10.1.1-rest&type=outgoing&apiKey=API_KEY_HERE'

Example

View a complete example.

Close Menu