HTTP Plugin
HTTP Plugin introduces five new actions that let you make requests to the RESTful API from your Alexa Skills and Google Actions:
This plugin is available to all BotTalk users - you are not required to activate the plugin to use those actions. You can see the overview of public BotTalk plugins in the Plugins Tab from the BotTalk dashboard.
The results of the requests fired by these actions are stored in the internal http_response
variable.
Note: We’ve created a complete step-by-step tutorial on how to create voice-based task manager using Trello API and BotTalk HTTP actions.
http.get
http.get
action lets you make a GET
request any API (retrieve a resource) and has following parameters:
headers
: An array with HTTP headers.url
: API endpoint URL.
Below is an example of this action requesting a Trello API.
- name: Read Cards in TODO List
actions:
- http.get:
url: 'https://api.trello.com/1/lists/5cb87630d107633274494541/cards?key=YOUR_TRELLO_KEY&token=YOUR_TRELLO_TOKEN'
- set: 'cards_in_list = http_response'
http.post
http.post
action fires a POST
request against a RESTful API (create a resource) and consists of the following parameters:
headers
: An array with HTTP headers.url
: API endpoint URL.payload
: Data payload sent in the body of thePOST
request in JSON format.
Below is an example of the http.post
action requesting a Trello API to create a new card:
- name: Create a New Task
actions:
- http.post:
url: 'https://api.trello.com/1/cards'
headers: ["Content-Type: application/json"]
payload: >
{
"name": "{{new_task_name}}",
"idList": "5cb87630d107633274494541",
"key": "YOUR_TRELLO_KEY",
"token": "YOUR_TRELLO_TOKEN"
}
http.put
http.put
action makes a PUT
request to a RESTful API (replace a resource) and has following parameters:
headers
: An array with HTTP headers.url
: API endpoint URL.payload
: Data payload sent in the body of thePUT
request in JSON format.
Below is an example of moving a Trello card to a new list using http.put
action:
- name: Move Task
actions:
- http.put:
url: 'https://api.trello.com/1/cards/{{ last_card.id }}'
headers: ["Content-Type: application/json"]
payload: >
{
"idList": "{{ list_id[destination_list_name] }}",
"key": "YOUR_TRELLO_KEY",
"token": "YOUR_TRELLO_TOKEN"
}
http.patch
http.patch
action fires a PATCH
request to a RESTful API (updates a resource) and has following parameters:
headers
: An array with HTTP headers.url
: API endpoint URL.payload
: Data payload sent in the body of thePATCH
request in JSON format.
http.delete
http.delete
action makes a DELETE
request to a RESTful API (deletes a resource) and has following parameters:
headers
: An array with HTTP headers.url
: API endpoint URL.payload
: Data payload sent in the body of thePATCH
request in JSON format.
Below is an example of the http.delete
action requesting a Trello API to delete a card:
- name: Delete Task
actions:
- http.delete:
url: 'https://api.trello.com/1/cards/{{ last_card.id }}'
headers: ["Content-Type: application/json"]
payload: >
{
"idList": "{{ list_id[source_list_name] }}",
"key": "YOUR_TRELLO_KEY",
"token": "YOUR_TRELLO_TOKEN"
}
Next Steps
Check out our Tutorials section and learn more about API Calls using BotTalk HTTP Plugin.