11
10

More than 5 years have passed since last update.

【Google Home開発】 Dialogflow V2になったWebhook API仕様の変更点まとめ

Last updated at Posted at 2018-06-07

先日 Dialogflow バージョンが V2 になってて Webhook APIのパラメータ仕様がいろいろ変わってたのでよく使う項目だけ抜粋してまとめました。

Dialogflow を使ってGoogle Homeに喋らせるときにはJSON形式で送ります。

V1の時は以下のような構造で送ってましたが、

V1の最低限のレスポンス
{
  "speech": "レスポンス",
  "displayText": "レスポンス"
}

V2になって項目が一つにまとまりました。

V2の最小限のレスポンス
{
  "fulfillmentText": "レスポンス"
}

リクエスト

よく使う項目を抜粋

V1
{
  "result": {
    "source": "agent",
    "resolvedQuery": "user's original query to your agent",
    "speech": "Text defined in Dialogflow's console for the intent that was matched",
    "action": "Matched Dialogflow intent action name",
    "actionIncomplete": false,
    "parameters": {
      "param": "param value"
    },
    "contexts": [
      {
        "name": "incoming context name",
        "parameters": {},
        "lifespan": 0
      }
    ],
    "metadata": {
      "intentId": "29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
      "webhookUsed": "true",
      "webhookForSlotFillingUsed": "false",
      "nluResponseTime": 6,
      "intentName": "Name of Matched Dialogflow Intent"
    },
    "fulfillment": {
      "speech": "Text defined in Dialogflow's console for the intent that was matched",
      "messages": [
        {
          "type": 0,
          "speech": "Text defined in Dialogflow's console for the intent that was matched"
        }
      ]
    },
    "score": 1
  },
  "originalRequest": {
    "source": "google",
    "version": "2",
    "data": {
      "isInSandbox": true,
      "surface": {
        "capabilities": [...]
      },
      "inputs": [...],
      "user": {...},
      "conversation": {...},
      "availableSurfaces": [...]
    }
  },
}
V2
{
  "queryResult": {
    "languageCode": "en",
    "queryText": "user's original query to your agent",
    "fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
    "action": "action name",
    "allRequiredParamsPresent": true,
    "parameters": {
      "param": "param value"
    },
    "outputContexts": [
      {
        "name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
        "lifespanCount": 5,
        "parameters": {
          "param": "param value"
        }
      }
    ]
  },
  "originalDetectIntentRequest": {
    "source": "google",
    "version": "2",
    "payload": {
      "isInSandbox": true,
      "surface": {
        "capabilities": [...]
      },
      "inputs": [...],
      "user": {...},
      "conversation": {...},
    }
  }
}

参考

Dialogflow API

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10