Calling 3rd party API
Calling a request for a 3rd party API using Jumper.ai
- 3rd party API
- Bot builder
In bot builder, now one can call 3rd party APIs within operations, below is an example of how you can call a request for a 3rd party API.
- Create a bot, add a message template and click on “Add a rule”, now under operations you need to select the option “Call 3rd party API”.
Now select an option for the request URL between POST and GET. Lets' say you need to get or fetch data, then you need to select the “GET” option and paste the link for the URL you want to request.
To get a sample response of the API you can paste your link under the “Example request URL”
(Note : You can’t use a variable in an example request URL such as “www.myurl.com/order/<orderid>”.)
In “Headers”, it is optional to provide your API KEY, Value and Example for your request URL.
(Note: You can only add variables in “VALUE” such as “<username>”, but under EXAMPLE, you have to use only hardcoded values.)
Refer to the image below:
You can add multiple Keys and Values in a request, once you have added fields for the first key, value and example press enter, you will be able to see a new row which will appear as shown below.
Once you have added your Key and Value hit the save button.
Once you have clicked on save you would be able to see your step added under operations, Now click on the edit button to check your API response.
Once you have successfully hit your request and got your response, now you can use the response data in your templates, such as email, name and last name of the user in your bot template from the response data that you received.
- Now add another message type, let's call it Step 2. Here we can use the response data from the API request in our message template.
(Note: Call API request in your first added message template, before you use the response data in your message template, as in this case, we are calling API request in step 1 and using the response data in step 2.)
- In Step 2, click on the insert option below the text box.
- Once you click on the “Insert” option, scroll down where you will find the field to enter the variable that you want to call in your template, as here we are going to use the user’s email in our template, once you have added the variable, then click on enter.
- Similar way, add the other fields like first name, last name, etc.
Now click on “Save” and “Publish” your bot.
Now test your bot to check if you get the response data in your bot template, your response data from the API request will reflect on the bot template similar as shown in the image below.
Please sign in to leave a comment.