我当时正在想作为一种解决我的问题的方法(Dialogflow automatically goes to Default Welcome Intent after follow up despite telling it not to)-无需阅读即可回答该问题-我可以控制使用Webhook代码将用户重定向到的意图。
我只是不确定如何访问用户在Webhook请求中所说的语音。用户将说出“生气,快乐,悲伤或自信”这四个词之一。我需要在Webhook代码中获取请求文本,然后根据用户使用的这四个单词中的哪个重定向用户。如何在下面的代码中做到这一点?
let intentMap = new Map();
intentMap.set('-Happy - noIncorrectEmotion', redirectEmotion);
agent.handleRequest(intentMap);
上面是问题'-Happy-noIncorrectEmotion'的意图的常规意图映射。我在想这个函数,redirectEmotion(agent)看起来像这样(如下):
function redirectEmotion(agent){
if(user.speech == 'angry'){ goToFunctionAssociatedWithAngry;}
if(user.speech == 'happy'){ goToFunctionAssociatedWithHappy;}
if(user.speech == 'sad'){ goToFunctionAssociatedWithSad;}
if(user.speech == 'confident'){ goToFunctionAssociatedWithConfident;}
}
{
"user": {
"locale": "en-US",
"lastSeen": "2019-08-10T18:59:25Z",
"userVerificationStatus": "VERIFIED"
},
"conversation": {
"conversationId": "ABwppHHx5dC2hnSE00NVc1ZjSEzyct6xXB4FVv4rP2tB2PWX7P6sGCsuwfsezT0rivBUvjReCMt-d7mYBmewN4A",
"type": "ACTIVE",
"conversationToken": "[\"-sad-followup-2\",\"-angry-followup-2\",\"-confident-followup-2\",\"-confident-followup\",\"-sad-followup\",\"-angry-followup\",\"-happy-followup\",\"-happy-followup-2\",\"checker\"]"
},
"inputs": [
{
"intent": "actions.intent.TEXT",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "angry"
}
],
"arguments": [
{
"name": "text",
"rawText": "angry",
"textValue": "angry"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.WEB_BROWSER"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.ACCOUNT_LINKING"
},
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
}
],
"requestType": "SIMULATOR"
}
TLDR:如何从请求到Webhook中获取“查询”部分?