使用邮递员在Google对话框流程V2 API中创建意图

时间:2020-03-26 11:10:48

标签: dialogflow-es

我正在尝试在Google对话框流程中创建的代理中创建意图。我可以通过Google API控制台创建意图。但是,当我通过Postman尝试相同操作时,却收到验证错误。我不确定我应该使用什么身份验证类型,为此我应该使用哪个密钥。在V2中用于创建意图的授权类型是什么,它是用于此的密钥,我在哪里可以获取这些密钥?

我在下面提供了我尝试过的细节。我想念什么或弄错了什么?

URL:https://dialogflow.googleapis.com/v2/projects/ {项目名称} / agent / intents?languageCode = en

授权:我用作密钥的oauth2和客户端ID

请求正文:

{
  "displayName": "ListRooms",
  "priority": 500000,
  "webhookState": "WEBHOOK_STATE_UNSPECIFIED",
  "trainingPhrases": [
    {
      "type": "EXAMPLE",
      "parts": [
        {
          "text": "What rooms are available at 10am today?"
        }
      ]
    }
  ],
  "action": "listRooms",
  "messages": [
    {
      "text": {
        "text": [
          "Here are the available rooms:"
        ]
      }
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

请尝试以下请求

  • 使用api网址

  • post方法在标头中发送请求

  • 将身份验证添加为承载, 您的开发者访问令牌和内容type = application/json

    {
      "contexts": [
        "shop"
      ],
      "events": [],
      "fallbackIntent": false,
      "name": "add-to-list3",
      "priority": 500000,
      "responses": [
        {
          "action": "add.list",
          "affectedContexts": [
            {
              "lifespan": 5,
              "name": "shop",
              "parameters": {}
            },
            {
              "lifespan": 5,
              "name": "chosen-fruit 1",
              "parameters": {}
            }
          ],
          "defaultResponsePlatforms": {
            "google": true
          },
          "messages": [
            {
              "platform": "google",
              "textToSpeech": "Okay. How many $fruit 1?",
              "type": "simple_response"
            },
            {
              "speech": "Okay how many $fruit?",
              "type": 0
            }
          ],
          "parameters": [
            {
              "dataType": "@fruit",
              "isList": true,
              "name": "fruit",
              "prompts": [
                "I didn't get that. What fruit did you want 1?"
              ],
              "required": true,
              "value": "$fruit"
            }
          ],
          "resetContexts": false
        }
      ],
      "templates": [
        "@fruit:fruit ",
        "Add @fruit:fruit ",
        "I need @fruit:fruit "
      ],
      "userSays": [
        {
          "count": 0,
          "data": [
            {
              "alias": "fruit",
              "meta": "@fruit",
              "text": "oranges",
              "userDefined": true
            }
          ]
        },
        {
          "count": 0,
          "data": [
            {
              "text": "Add "
            },
            {
              "alias": "fruit",
              "meta": "@fruit",
              "text": "bananas",
              "userDefined": true
            }
          ]
        },
        {
          "count": 0,
          "data": [
            {
              "text": "I need "
            },
            {
              "alias": "fruit",
              "meta": "@fruit",
              "text": "apples",
              "userDefined": true
            }
          ]
        }
      ],
      "webhookForSlotFilling": false,
      "webhookUsed": false
    }

希望获得帮助