What is it for?

The API action lets you make an API request to any URL. As of now, the feature only allows you to make a GET request, where you can specify query string parameters.

How to use it?

URL

In the URL field, you can copy and paste the API URL. You can use context variables in the URL if needed, as an example: https://myapi.com/contracts/{contractNumber}.

In this example, {contractNumber} will be replaced by the value of the context variable. So, if {contractNumber} equals 012345, then the request will be sent to https://myapi.com/contracts/012345.

Headers

You can add as many HTTP headers as you need. Just like the URL, you can use context variables in the value field if you need to.

If you need to use a Basic Authentication (username and password), you have to add an Authorization header. As a header value, you have to put Basic username:password by replacing the string username:password with the real value and the whole string must be encoded in base64.

As a result, you should have something like the following:

authorization header.png

Add response data to context

Once the API request is done, you will most likely want to use this data in your discussion script. To achieve that, you have to store the data you want into the discussion context.

If you need to retrieve specific data from the API response, you can specify a path to the data, and specify in which context variable to store the data, like the following:

output context.png

This will look for path.to.the.data in the API response, and store it in the context variable myData.

If you need to use myData in a Say action, you can type “This is {myData}” and {myData} will be replaced by the value of the context variable.