Google Assistant埋め込みサンプルコード

Actions on Googleの埋め込み方のシンプルサンプルコードです。

シンプルサンプルコードは公開されております。そのまま貼り付けます。ご興味のある方はどうぞ。
console.actions.google.comにログインする必要があります。

Build Actions for the Google Assistant with Actions on Google.

Conversation Webhook Format
“Ok Google, talk to My Favorite Shoe Store”
“Ok Google, talk to My Favorite Shoe Store to buy some shoes”
“Ok Google, talk to My Favorite Shoe Store to check on my order”
“Ok Google, talk to My Favorite Shoe Store to show me today’s deals”

{
"actions": [
{
"name": "MAIN",
"intent": {
"name": "actions.intent.MAIN"
},
"fulfillment": {
"conversationName": "sekai-app"
}
},
{
"name": "BUY",
"intent": {
"name": "com.example.sekai.BUY",
"parameters": [{
"name": "color",
"type": "org.schema.type.Color"
}],
"trigger": {
"queryPatterns": [
"find some $org.schema.type.Color:color sneakers",
"buy some blue suede shoes",
"get running shoes"
]
}
},
"fulfillment": {
"conversationName": "sekai-app"
}
},
{
"name": "ORDER_STATUS",
"intent": {
"name": "com.example.sekai.ORDER_STATUS",
"trigger": {
"queryPatterns": [
"check on my order",
"see order updates",
"check where my order is"
]
}
},
"fulfillment": {
"conversationName": "sekai-app"
}
},
{
"name": "DAILY_DEALS",
"intent": {
"name": "com.example.sekai.DAILY_DEALS",
"trigger": {
"queryPatterns": [
"hear about daily deals",
"buying some daily deals",
"get today's deals"
]
}
},
"fulfillment": {
"conversationName": "sekai-app"
}
}
],
"conversations": {
"sekai-app": {
"name": "sekai-app",
"url": "https://sekai.example.com/sekai-app"
}
}
}

非常にシンプルな会話形式を呼び出して返す。

{
  "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"
        }
      ]
    }
  ]
}

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"
        }
      ]
    }
  ]
}

End conversation example

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

developers.google.com
Actions on Google