Help us understand the problem. What is going on with this article?

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

More than 1 year has passed since last update.

先日 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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away