Reputation: 626
Can I connect my web application with Dialogflow API?
I want send http requests to Dialogflow api and get responses to my chatbot application. I tried with Web Demo but I want to build my own interface.
Upvotes: 0
Views: 187
Reputation: 160
You can use api-ai-javascript library: https://www.npmjs.com/package/api-ai-javascript
This works for me:
import { ApiAiClient } from 'api-ai-javascript'
const client = new ApiAiClient({ accessToken: this.token, lang: this.lang});
client.textRequest(text, { originalRequest: {} })
.then((response) => console.log(response));
The example in the npm library didn't work for me as I had to add the { originalRequest: {} } parameter.
Upvotes: 0
Reputation: 668
The Dialogflow API is introduced in a few Google Codelabs, linked below:
Build Actions for the Google Assistant (Level 1) https://codelabs.developers.google.com/codelabs/actions-1/#0
Build Actions for the Google Assistant (Level 2) https://codelabs.developers.google.com/codelabs/actions-2/index.html#0
After finishing the level 2 codelab, you should be ready to handle incoming HTTP requests and provide the appropriate responses.
Upvotes: 1