The API Call node is a powerful feature designed to integrate your AI Assistant with external systems through REST APIs. This capability allows your AI to interact with a wide range of services and databases, including:
Customer Relationship Management (CRM) systems
Ticketing systems
Databases
Enterprise Resource Planning (ERP) software
And any other external service that has a REST API
By leveraging this node, your AI Assistant can not only access information but also take actions and complete tasks, significantly enhancing its functionality and usefulness.
Configuration Tab
The configuration of the API Call node is crucial for its proper functioning. Let's explore the key elements of the Configuration Tab.
Method
Method Selection Choose the appropriate REST method for your API call:
GET: Retrieve data from the specified resource
POST: Submit data to be processed to the specified resource
PUT: Update existing data at the specified resource
DELETE: Remove the specified resource
PATCH: Partially update existing data at the specified resource, modifying only the fields provided without affecting the rest.
Note: For POST, PUT, PATCH, DELETE) For methods that allow sending data, you'll need to provide a JSON-formatted body. This is where you'll include the data you're sending to the API.
URL
Enter the complete URL of the API endpoint you're calling.
Note: You can add variables to the URL!
Headers
Specify any required HTTP headers for the API call. Common headers include:
Content-Type: application/json
Authorization: Bearer [your_token_here]
You can add or delete headers by clicking on the + and - icon
Parameters
If your API requires query parameters, you can add them here. These will be appended to the URL.
Note: You can add variables too!
Capture Response Tab
The Capture Response tab in the API Call node allows you to store and utilize the data received from your API request. Here's how to use it effectively:
Click on the Response Capture Toggle and add a variable.
Select Variable Choose a variable to store the API response. The default is "last_api_response", which can be used in subsequent nodes.
Specify Key (Optional) Enter a specific key from the API response you want to capture. For example, "records" will store only the "records" portion of the response.
Test Response Click "Test response" to validate your configuration and preview the captured data.
By configuring this tab, you ensure that relevant data from your API call is accessible throughout your conversation flow, enabling more dynamic and data-driven interactions.
Remember: The captured response can be referenced in later nodes, allowing your AI to use this information in crafting responses or making decisions.
Testing Responses
The API Call node provides a robust testing feature to ensure your integrations work as expected before deploying them in your conversation flow. Here's a detailed guide on how to use and interpret the test results:
Initiating the Test Click the "Test Response" button to begin. If your URL includes variables, you'll be prompted to input test values for these variables manually. This allows you to simulate different scenarios.
Test Results Overview After running the test, you'll receive a comprehensive breakdown of the API response: a) Status: The HTTP status code (e.g., 200 for success, 404 for not found, 500 for server error) b) Payload Size: The size of the response data in bytes c) Response Time: How long the API call took to complete, typically in milliseconds
Detailed Response Information The test results provide three views of the response data: a) Body: The main content of the response, usually in JSON format. This is where you'll find the data you requested from the API. b) Headers: HTTP response headers, which can include important metadata about the response c) Raw: The complete, unprocessed response, useful for troubleshooting or when you need to see every detail
Node Connections
Input:
The API Call node has a single input connector, allowing it to be linked with preceding nodes in your conversation flow. This connection is crucial for passing data between nodes.
Key Features:
Variable Passing: Receives variables captured or generated by previous nodes.
Dynamic Configuration: Uses passed variables to customize the API call.
Example: AI Assistant Node โ API Call Node
AI Assistant captures an order number from the user.
The order number is passed to the API Call node.
API Call uses this number to fetch order details from an external service.
Use Case: User: "I want to check my order status." AI Assistant: Captures order number as {order_number} API Call: Sends GET request to "https://api.example.com/orders/{order_number}"
This setup allows for dynamic, context-aware API calls based on user interactions, enhancing the responsiveness and flexibility of your conversational flow.
Outputs:
The API node has two output connectors:
Success: Triggered when the API call is successful (typically HTTP 200-299 status codes)
Fail: Triggered when the API call fails (e.g., 400, 404, 500 status codes)
Example:
Success: Proceed to an AI Assistant node if the API call is successful
Fail: Handle errors or retry logic if the call fails
The success and fail outputs allow you to create different conversation flows based on the API response, ensuring smooth handling of both successful operations and potential errors.