代码中的dialogflow请求有什么问题(与邮递员一起使用)?

编程入门 行业动态 更新时间:2024-10-23 22:22:14
本文介绍了代码中的dialogflow请求有什么问题(与邮递员一起使用)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的聊天机器人应用程序有问题。我只是没有发现为什么我无法用代码中的请求调用dialogflow API的错误,因为它很难与邮递员的相同请求一起使用。甚至dialogflow支持人员都说该请求是正确的。还是不会自动将javascript代码更改为json对象?

下面,我向您发送了我的应用程序代码(代码段1),这是代码请求的实际结果(代码段) 2),当我使用邮递员(代码片段3)时返回想要的结果,以及dialogflow中意图的屏幕截图(屏幕截图1)。

代码片段1 :我的应用程序代码

const fetchAnswerFromDialogflow = async(userInput,currentChatbotInEdit)=> { const config = {标头:{授权: Bearer + clientToken, Content-Type: application / json; charset = utf-8,},}; const请求= { queryParams:{上下文:[ {名称:`projects / myteachingbot-arxmxd / agent / session / myteachingbot-session $ {state.sessionId} / contexts / Chatbotcontext726`, lifespanCount:1,}, { name:`projects / myteachingbot -arxmxd / agent / sessions / myteachingbot-session $ {state.sessionId} / contexts / Chatbotcontext7262` inputContext1, lifespanCount:1,},], resetContexts:true,}, queryInput:{ text:{ text:userInput, languageCode: en-US, },},}; try { const res = await axios.post(`dialogflow.googleapis/v2/projects/myteachingbot-arxmxd/agent/sessions/myteachingbot-session$ { state.sessionId}:detectIntent`,请求,配置); console.log(res); }

代码段2:代码请求的实际结果

{ responseId: 8a9ead3d-f3ea-4a75-b110-257454069382-425db6e2, queryResult:{ queryText: start, parameters:{}, languageCode: en } }

代码段3:返回的通缉结果邮递员:

{ responseId: f8ea7646-576a-4789-a88f-d0f80416de84-425db6e2 , queryResult:{ queryText: start, parameters:{}, allRequiredParamsPresent:true, fulfillmentText: Frage 1, fulfillmentMessages:[ { text:{ text :: [ Frage 1 ] } } ],意图:{名称: projects / myteachingbot-arxmxd / agent / intents / 70aa4273-5368-4a40-acc3-484c8ad415df, displayName: Frage7261 }, intentDetectionConfidence:1, languageCode: en } }

解决方案

如果您提供的意图是您希望触发的意图,则不会被任何触发

Dialogflow仅在将事件作为检测意图请求的一部分发送时,才会触发包含该事件的意图。

I have a problem with my chatbot Application. I just don't find the mistake why I can't call the dialogflow api with my request from code tough it works with the exact same request from postman. Even the dialogflow support says that the request is correct.

Can it be blocked somehow from dialogflow? Or does it not automatically change the javascript code into a json object?

Below I send you the code of my application (code snippet 1), the actual result from the code request (code snippet 2), the wanted result as it comes back when I use postman (code snippet 3), and the screenshot of the intent in dialogflow (screenshot 1).

code snippet 1: code of my application

const fetchAnswerFromDialogflow = async (userInput, currentChatbotInEdit) => { const config = { headers: { Authorization: "Bearer " + clientToken, "Content-Type": "application/json; charset=utf-8", }, }; const request = { queryParams: { contexts: [ { name: `projects/myteachingbot-arxmxd/agent/sessions/myteachingbot-session${state.sessionId}/contexts/Chatbotcontext726`, lifespanCount: 1, }, { name: `projects/myteachingbot-arxmxd/agent/sessions/myteachingbot-session${state.sessionId}/contexts/Chatbotcontext7262` inputContext1, lifespanCount: 1, }, ], resetContexts: true, }, queryInput: { text: { text: userInput, languageCode: "en-US", }, }, }; try { const res = await axios.post( `dialogflow.googleapis/v2/projects/myteachingbot-arxmxd/agent/sessions/myteachingbot-session${state.sessionId}:detectIntent`, request, config ); console.log(res); }

code snippet 2: the actual result from the code request

{ "responseId": "8a9ead3d-f3ea-4a75-b110-257454069382-425db6e2", "queryResult": { "queryText": "start", "parameters": {}, "languageCode": "en" } }

code snippet 3: the wanted result that I get returned from postman:

{ "responseId": "f8ea7646-576a-4789-a88f-d0f80416de84-425db6e2", "queryResult": { "queryText": "start", "parameters": {}, "allRequiredParamsPresent": true, "fulfillmentText": "Frage 1", "fulfillmentMessages": [ { "text": { "text": [ "Frage 1" ] } } ], "intent": { "name": "projects/myteachingbot-arxmxd/agent/intents/70aa4273-5368-4a40-acc3-484c8ad415df", "displayName": "Frage7261" }, "intentDetectionConfidence": 1, "languageCode": "en" } }

解决方案

If the Intent you've provided is the Intent you expect to be triggered - it won't be triggered by any of the Training Phrases since an Event is set for it.

Dialogflow will only trigger an Intent that contains an Event if that Event is sent as part of the Detect Intent request.

更多推荐

代码中的dialogflow请求有什么问题(与邮递员一起使用)?

本文发布于:2023-10-29 04:00:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538661.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   邮递员   代码   dialogflow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!