[英]How to use Dialogflow Api.ai V2 in ionic App
I have created a Dialogflow V2 agent and am trying to integrate the same with ionic 4 App.我创建了一个 Dialogflow V2 代理并尝试将其与 ionic 4 App 集成。
Steps Followed :遵循的步骤:
Here the problem is when I use the same access token in my ionic app or even in the postman, am getting 401 unauthorized Invalid access token error .这里的问题是,当我在我的 ionic 应用程序甚至 postman 中使用相同的访问令牌时,我收到401 authorized Invalid access token error 。
I have followed the below link to create the Ionic App https://www.yuribacciarini.com/integrate-dialogflow-chatbot-on-ionic-app/我按照以下链接创建了 Ionic App https://www.yuribacciarini.com/integrate-dialogflow-chatbot-on-ionic-app/
API CALL: API 致电:
I am using Native HTTP call我正在使用本机 HTTP 调用
import { HTTP } from '@ionic-native/http/ngx';
private nativeHttp: HTTP
let encUrl = "https://dialogflow.googleapis.com/v2/projects/id/agent/sessions/id:detectIntent";
return from(this.nativeHttp.post("URL", data, headers)
.then(res => {
console.log(res); //Returning [object object]
console.log(JSON.stringify(res)); //Returning data as single string
return res;
}, (error: any) => {
return this.handleError(error);
}));
Response:回复:
In this response data returned as string.在此响应中,数据以字符串形式返回。 I have tried to parse the data and if I take response.data.queryResult or Response.queryResult it shows undefined .
我试图解析数据,如果我采用response.data.queryResult 或 Response.queryResult 它显示 undefined 。 Thanks & Regards, Janani
谢谢和问候,贾纳尼
The blog you are following is out dated.您关注的博客已过时。
To communicate with dialogflow API you need to have access token.要与对话流 API 进行通信,您需要拥有访问令牌。
You can follow API v2 guide,您可以遵循 API v2 指南,
https://chatbotslife.com/dialogflow-v2-rest-api-communication-6cf7ab66ab36 https://chatbotslife.com/dialogflow-v2-rest-api-communication-6cf7ab66ab36
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.