dialogflow-es - 使用 postman 在 Google 对话流 V2 API 中创建意图
问题描述
我正在尝试在我在 google 对话流中创建的代理中创建意图。我可以通过 Google API 控制台创建意图。但是当我通过 Postman 尝试相同的操作时,我遇到了身份验证错误。我不确定我应该使用的授权类型到底是什么,我应该为此使用哪个密钥。在 V2 中用于创建意图的授权类型是什么?用于此目的的密钥是什么?我在哪里可以获得这些密钥?
我在下面提供了我尝试过的详细信息。我错过了什么或犯了什么错误?
网址: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:"
]
}
}
]
}
解决方案
请尝试以下请求
使用 api 网址
在标头中发送请求的 post 方法
添加身份验证作为 Bearer,您的开发人员访问令牌和内容
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
}
希望这有帮助
推荐阅读
- javascript - 为什么将 Buefy 导入我的 Vuejs 项目会使
- excel - 有没有办法使用 Google appscript 从 Bigquery 结果生成 Microsft Excel?
- python - kivy中的登录界面
- php - 如果条件允许,则创建视图表
- php - 根据当前会话选择计数联合
- go - 结构片不能插入golang中的接口片
- cucumber - 如何在黄瓜步骤定义中实现httpAuth
- jmeter - 未找到密钥库文件,正在加载空密钥库
- firebase - react-native 链接为 react-native-firebase 提供错误
- git - 如何将 master 合并到作为拉取请求提交的分支中?