node.js - Dialogflow API HTTP 请求查询代理不起作用
问题描述
最近我在使用nodeJs 服务器上的Dialogflow API时遇到了一些问题……所以我有一个聊天机器人 GUI,可以将 HTTP 请求发送到 dialogflow 代理(使用 dialogflow API v1),而这个基于用户查询应该发送响应。但是现在,IT 发送了一个错误401 未授权,知道从那以后没有任何代码被更新!我已经放置了调用 dialogflow API 的函数并添加了一些 console.log() 进行调试。该错误位于函数 textRequest 内。
import { ApiAiClient } from 'api-ai-javascript'
const client = new ApiAiClient({accessToken: MY_ACCESS_TOKEN});
methods: {
dialogflowRequest(queryText){
document.querySelector('.submit-input').style.opacity = '0.5';
console.log("==> dialogflow request");
client.textRequest(queryText).then((response) => {
console.log("==> client request");
if(response.result.action == "input.unknown" && this.config.app.googleIt == true){
response.result.fulfillment.messages[0].unknown = true
response.result.fulfillment.messages[0].text = response.result.resolvedQuery
}
document.querySelector('.submit-input').style.opacity = '1';
//this.speak(response);
this.handle(response);
// VueJS will update the HTML automatically
this.answers.push(response);
//reset query and speech
this.query = '';
this.speech = config.locale.strings.voiceTitle;
}).catch((error) => {console.log("unable to log into dialogflow!!!");console.log(error);})
}
POST https://api.api.ai/v1/query?v=20150910 401(未经授权)
==> 经过一番检查
{"status":{"code":401,"errorType":"unauthorized","errorDetails":"缺少身份验证参数"}}
解决方案
推荐阅读
- javascript - 大型 API 的分页
- c# - 如何在 JetBrains Rider 中添加/使用 C# 库?
- lua - 如何在 OSX 或 32 位 core.so 上安装 32 位 luasocket
- android - 如何导入和同步 BitBucket 项目
- java - 如何在 spring-boot 中获取实体的所有元素?
- angular - 尝试传递请求选项时出错
- c - C 编译器参考实现
- angularjs - 为什么 AngularJS $compile 不执行 javascript 代码?
- angularjs - 在angularjs中编辑内容时取消功能不起作用?
- wordpress - paginate_links() 在查询字符串中显示当前页面