Using the Call API feature (Beginner)

Hello, I am very new to Botpress and i have been doing some practise on it, thanks to this community.
I am using: Botpress Server Version 11.8.4

I have been trying to use the call API function with no success.

in this guide : ,

i am assuming the goal here is to use the bot to display the different categories and sub categorues in the spotify api.

This is how it should display as an example

Category = America Subcategory =country music , hiphop music
Category = uk Subcategory =House music , rock music

The bot should be able to display the categories and the sub categories on request.

In the examples, Can one explain to me what is actually going on in each step?

Part 1
The circled part .

What is that command , and what does it mean?

Part 2

Do you leave that space just below the comment empty or should i post my json response which am getting when i use postman?.

Part 3

What should i place here ?

Part 4

I understand on the use of {{temp.response}}, but i don’t understand where the response is being displayed. Is The saved response object, similar to the json i get when i run the api from postman?

Part 5
I understand what templating is, but how can i apply it on botpress server so that my bot can function effectively, and what type of json code do i put on the header and body section?

Please I need some step by step guidance, So that i can understand. I have searched for a proper you tube tutorial in vain.

Also, if you look at the picture, you can see this getToken(args) action being used in the entry node, or rather, the get-auth-token node.

There is NO metion of this getToken in the documentation. Also, if you try to acess the API provided in the example, you will find an error.

I am also having the same trouble.

I still havent solved my issue but am actively reading up on using Axios to make my own customcall Api. I will keep you updated if i finally crack this. Please do if you also succeed on your end :slight_smile:

Yeah, creating our own custom API seems the way to go here, but i am having trouble because my JS and JSON skills are not good.

The erros in the documentation also don’t help.

You can start here …

This link will give you an idea of how to use axios. Axios is already packaged within botpress 11+

From here, you can learn how to get or post data with api.

I will share my custome code once am done creating :slight_smile:

1 Like

Nice, i will begin right away. I will share mine as well

Hi @kenkaigu, @caiolindo,

Part 1) That command uses Mustache templating to make string interpolation so you can use the variable directly in the string. {{}} takes the name of the first category in the list. Because we mapped the response to session.response, the API response will be available there.
Part 2) The request body is a payload that you send to the API. In this case, it can be left blank.
Part 3) Most API’s use requests headers for some form of authentication method. It this case, it should be an Authorization header with the token that Spotify has generated for you.
Part 4) The data that is saved in memory is the raw API response (what you’d get in Postman).

The getToken node is just using memory to store my Spotify auth token so I can use templating in my Call API skill to recover it. This is only to be sure my token is not exposed on the client side.

Hope this helps.

Hi, were you able to create your custom call, can you share your code?
I have a similar requirement How to get json object in botpress custom component?
Please have a look. Thanks.