嗨,为了集成Angular 6和dialogflow,我看到了两种不同的方式。1.一个是使用Api-ai-javascript包,该包在dialogflow v2版本中存在一些问题
import { ApiAiClient } from 'api-ai-javascript';
client = new ApiAiClient({ accessToken: this.token });
this.client.textRequest(msg)
.then(res => {
const speech = res.result.fulfillment.speech;
const botMessage = new Message(speech, 'bot');
this.update(botMessage);
});也可以直接调用https://api.dialogflow.com/v2/query?v=20150910接口;
private baseURL: string = "https://api.dialogflow.com/v2/query?v=20150910";
public getResponse(query: string){
let data = {
query : query,
lang: 'en',
sessionId: '12345'
}
return this.http
.post(`${this.baseURL}`, data, {headers: this.getHeaders()})
.map(res => {
return res.json()
})
}链接here示例
这是对话流集成Api的推荐方式。ai包似乎没有被广泛使用,请给我一些建议和最佳实践?
发布于 2019-03-01 00:53:36
我找到了一些YouTube教程,它们可能对我有所帮助:
https://stackoverflow.com/questions/54896282
复制相似问题