Integrations
Overview
Integrations allow your chatbot to interact with external systems via API calls, enabling real-time data retrieval and automated actions. This ensures a more dynamic and intelligent chatbot experience.
The Integrations section can be found under the Advanced tab in the left-hand sidebar of BotStudio.
Understanding API Integrations
BotStudio primarily supports REST API integrations, which allow the chatbot to send and receive data from external systems. Key requirements:
- The API endpoint must be accessible from the server (consult Puzzel for details).
- The API response must be in JSON format and include a data field containing the relevant payload.
- Often, businesses create a wrapper API to handle backend logic and format responses correctly for the chatbot.
Adding an Integration
Integrating an API into BotStudio involves two steps:
- Defining the action (creating the integration blueprint).
- Using the action in a chatbot node (invoking the integration at runtime).
Steps to Add a New Integration
- Navigate to the Integrations page in BotStudio.
- Click Add Custom Integration.
- In the pop-up, fill in the following details:
- Name: A descriptive name for the integration (e.g.,
FetchUserData
). - REST Endpoint: The URL of the API.
- Request Type: Choose between
GET
,POST
,PUT
,PATCH
orDELETE
. - Response Format: Indicate if the relevant data is located under the
data
key. - Headers: Add HTTP headers like authentication tokens or content-type specifications.
- Parameters: Define query parameters (for GET requests) or request body parameters (for POST requests).
- Timeout: Set a response timeout (default: 120s; recommended: 10s for fast responses).
- Path Parameters: Enable value appending to the endpoint path if required.
- Mock Response: Provide a sample API response for testing.
- Test Action: Verify the connection before saving.
- Name: A descriptive name for the integration (e.g.,
- Click Save to finalize the integration.
Using an Integration in a Chatbot Node
Once an integration is created, it can be added to chatbot nodes as an action.
Steps to Invoke an Integration in a Node
- Open the node editor for the target chatbot node.
- Add a new activity of type Action.
- Select the desired integration from the list.
- Fill in dynamic parameters using chatbot variables.
- Define the target variable where the API response will be stored.
- Save and test the chatbot.
Best Practices for Integrations
- Fail Fast: If an endpoint is slow, set a lower timeout and inform users of delays.
- Secure API Calls: Use authentication headers to protect sensitive data.
- Error Handling: Implement fallback messages for failed requests.
- Optimize Requests: Minimize redundant API calls to improve speed.