Use the call api node in chatbot
You can use the “Call API” to call an api from the chatbot itself. You can even use the response of the API in the chatbot flow.
Configuration
-
API - You can select or configure the api details from the API section
- Click on "Show Editor" update the API configuration
- If you are using a json payload, you can type
{{to show a list of available variable substitutions - You will have access to the last chat message text and the data collected via the chatbot

-
Store response in variable? - Provide a variable name to store the api response in a variable
-
JSON path of value to store? - Provide a json path to extract a certain specifc value from the JSON response and store in the variable
- The api response is accessed with the key response.data
- so if your api response is
{ "value": "this is the response" } - then the jsonpath should be response.data.value

Output
The API will either result in a success (2xx response) or a failure (non 2xx response). You can link the options to furtherr nodes accordingly.

Guide
Below is a step by step guide to building a new chatbot with “Call API Node”
- Create new chatbot from https://app.chakrahq.com/admin/chatbot-settings#chatbots
- Edit the welcome node and provide a welcome message like “Welcome”
- Click Save to close the welcome node editor
- Drag and drop a “ask a question” node to the right of the welcome node
- Link the welcome node to the “ask a question” node
- Edit the question node, and under the “Text” input add a question like “What is your query?”
- Under “Store in a variable” add a variable name like “query”
- Click Save to close the question node editor
- Drag and drop the “Call API” node to the right of the question node
- Edit the “Call Api” Node
- Click “Show Editor” next to the selected API
- Make necessary changes like providing the api url and selecting the http method
- Chose “form url encoded” or “form multipart” from the body type
- Click “Add Another” under the “key value” section
- A new entry will be created - under key provide the key name like “text”, Under value select the query variable
- Click “Save API” to close the editor
- Under “Store response in variable” add a variable name like api_response
- Under “JSON path of value to store” add a json path to select a specific value from the api response to store
- The api response is accessed with the key response.data
- so if your api response is
{ "value": "this is the response" } - then the jsonpath should be response.data.value
- Click “Save" to close the api node editor
- Drag and drop a message node to the right of the api node
- Connect the Success option of the api node to the new message node
- Edi the message node
- Type in a message for the message node. If you want to access the data returned in the api node, type @ and start typing to get a menu of variables available. Choose ‘api_response’ variable
- Click save to save the message node
- Click Save from the top right corner to save the chatbot
This chatbot will ask user a question and then hit your configured api with the user response. If an api response is received then the response is sent back to the user.
