The Call Webhook tool empowers your AI agent to interact with external HTTP REST APIs, enabling it to perform a wide range of actions beyond its default capabilities. By configuring this tool, you can integrate your agent with other systems, automate tasks, and enhance conversations with real-time data. This guide will walk you through the configuration and usage of the Call Webhook tool, complete with examples to illustrate its functionality.
The Call Webhook tool allows your AI agent to:
To set up the Call Webhook tool, you'll need to configure several parameters:
Description: A brief explanation of what the tool does. This helps you reference the tool in your instructions.
Example: "Submit Ticket"
URL: The endpoint URL of the API you want to call.
Example: "https://api.example.com/tickets"
Method: The HTTP method to use for the request (e.g., GET, POST, PUT, DELETE).
Example: "POST"
Headers: Any custom headers required by the API, such as authentication tokens or content types.
Example:
{
"Authorization": "Bearer your_api_token",
"Content-Type": "application/json"
}
Query String Parameters: Parameters to include in the URL's query string. You can use variables collected from the conversation.
Example: "?email=$email&status=open"
Body: The request body for POST or PUT requests, formatted as valid JSON. Variables from the conversation can be inserted here.
{
"name": "$name",
"email": "$email",
"message": "$additional_info"
}
Response Identifiers: Specify keys from the JSON response that the agent can access, using dot notation. This limits the data the agent can use in the conversation.
Example: "ticket_id", "status", "assigned_to.name"
Determine what you want the AI agent to achieve by calling the webhook. This could be anything from creating a support ticket, fetching account information, to scheduling an appointment.
Example Scenario: When a customer wants to submit a support ticket.
Instruct your AI agent on how to interact with the caller and when to use the Call Webhook tool.
Instruction Example:
"Collect the caller's name, email, and a description of their issue. Then, use the 'Submit Ticket' tool with variables $name, $email, and $issue_description. Once the ticket is created, inform the caller of their ticket ID."
This tells the agent to:
Collect Information: Gather necessary details from the caller.
Call the Webhook: Use the tool to send data to the external API.
Utilize the Response: Extract specific information from the API response to continue the conversation.
Using the configuration parameters, set up the tool as per your requirements.
Example Configuration:
{
"Authorization": "Bearer abc123token",
"Content-Type": "application/json"
}
{
"customer_name": "$name",
"customer_email": "$email",
"issue": "$issue_description"
}
Use variables to capture data from the conversation. Variables are denoted by a dollar sign ($) followed by the variable name.
Variable Examples:
Specify how the agent should use the data returned from the API call.
Example:
After receiving the ticket_id from the API response, the agent can say:
"Thank you, $name. Your support ticket has been created. Your ticket ID is $ticket_id. Our team will reach out to you shortly."
Scenario: A customer wants to check the status of their order.
Instructions:
Configuration:
{
"Authorization": "Bearer your_api_token"
}
Agent's Dialogue:
Scenario: A client wants to schedule an appointment.
Instructions:
Configuration:
{
"Authorization": "Bearer your_api_token",
"Content-Type": "application/json"
}
{
"client_name": "$name",
"appointment_date": "$date",
"service_type": "$service"
}
Agent's Dialogue:
When the API returns a JSON response, you can specify which parts of the response the agent can access using response identifiers.
Example Response:
{
"ticket": {
"id": "TICKET123",
"status": "open",
"assigned_to": {
"name": "Support Agent",
"email": "[email protected]"
}
},
"message": "Ticket created successfully."
}
Response Identifiers:
By specifying these identifiers, you control what information the agent can use, enhancing security and relevance.
Ensure Valid JSON: The body of POST or PUT requests must be valid JSON. Double-check for syntax errors.
Secure Data Transmission: Use HTTPS URLs and include necessary authentication headers to protect data.
Variable Naming: Use clear and consistent variable names that match the data being collected.
Error Handling: Instruct the agent on what to do if the API call fails or returns an error.
Example Instruction:
"If the 'Submit Ticket' tool fails, apologize to the caller and inform them that we will follow up via email."
Testing: Before deploying, test the webhook calls to ensure they work as expected and the agent handles the responses correctly.
You can include variables in the query string to pass data via the URL. Your agent already knows a lot of information from the conversation, things like current date and time, caller's caller ID information (if available), callers phone number (if on a phone call) and more. You can use all this information by instructing the agent as well.
Example 1:
Example 2:
Include custom headers for APIs that require them, such as:
Ensure the method matches the API's requirements.
Use the data returned from the API to make the conversation more informative.
Example:
Scenario: Providing real-time stock levels.
Agent: "Let me check the availability of that item."
Agent: (Calls the webhook and retrieves the stock level)
Agent: "We currently have $stock_quantity units available."
The Call Webhook tool extends your AI agent's functionality by enabling it to interact with external APIs. By carefully configuring the tool and writing clear instructions, you can automate tasks, provide real-time information, and create a more engaging and efficient experience for your customers.
Remember to:
By mastering the Call Webhook tool, you unlock a powerful mechanism to integrate your AI agent with the broader digital ecosystem, enhancing both your operations and customer interactions.
You can visit the Tool Usage guide for a brief overview of all the tools.
Find out how to leverage the full capabilities of echowin for customer service....
Learn how to send text messages to your callers during the call....
Learn how you can leverage special instructions to make your agent even more powerful....