Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HTTP Request for Google Dialogflow

https://api.dialogflow.com/v1/query?v=20150910&contexts=shop&lang=en&query=apple&sessionId=12345&timezone=America/New_York

Headers: Authorization: Bearer YOUR_CLIENT_ACCESS_TOKEN

How do i use the above code to make a HTTP Request in Google Dialogflow? How do i add headers as a part of HTTP request

like image 232
sajeet Avatar asked Mar 13 '18 08:03

sajeet


People also ask

How use Dialogflow REST API?

From Postman, create a new Request and select the “Authorization” tab and choose Type "OAuth 2.0". Click 'Get New Access Token'. See the Dialogflow API Rest reference for the full list of APIs you can query. From Postman, enter the API you want to query in the GET field.


2 Answers

You can use the Postman application for sending POST request,

Select Post request in Postman Application,

Copy and paste URL https://api.dialogflow.com/v1/query?v=20150910&contexts=shop&lang=en&query=apple&sessionId=12345&timezone=America/New_York

In headers section, choose Authorization as key and paste the Bearer YOUR_CLIENT_ACCESS_TOKEN

Then, if you click send you will get the proper response in a body.

like image 52
Nikhil Savaliya Avatar answered Oct 12 '22 01:10

Nikhil Savaliya


An easy start is to use curl from the command line as in the documentation:

curl \
-H "Authorization: Bearer YOUR_CLIENT_ACCESS_TOKEN" \
"https://api.dialogflow.com/v1/query?v=20150910&contexts=shop&lang=en&query=apple&sessionId=12345&timezone=America/New_York"

Just copy the whole thing and paste it into your command line and you will get a json response.

Ref: https://dialogflow.com/docs/reference/agent/query#get_query_sample

like image 40
Candy Tsai Avatar answered Oct 12 '22 01:10

Candy Tsai