Web Client
Web Client Actions are AI-powered tools that your website's Copilot can use to perform tasks directly from the web widget. These tools are designed to help users interact with your website more efficiently and effectively.
Note: You need to set up the Copilot Web Widget deployment first before using Web Client Actions. Please follow the deployment guide to embed and configure the Web Widget on your website. Once the widget is live, you can start adding and managing AI-powered Web Client Actions as described below.
What Are Web Client Actions?
Think of Web Client Actions as giving your website's AI assistant (Copilot) the ability to help you directly. Instead of just chatting, it can now perform tasks for you! For example:
- When you say "Show my cart", it actually opens your shopping cart
- When you ask "Add this shirt", it puts the item in your cart
- When you say "Go to homepage", it takes you there
It's like having a helpful friend who can click buttons and fill forms for you - you just need to ask!
Benefits
-
Easier to Use Just tell the assistant what you want - no more searching through menus
-
Save Time One command does multiple tasks - like "Add 2 shirts to cart" handles everything
-
Fewer Mistakes The assistant follows exact steps every time
Create Your Actions
Each action needs these parts:
- Name: What to call this action (like "add_to_cart")
- Description: What it does
- Timeout: Maximum time to wait (in milliseconds)
- Parameters: What information the action needs (like product ID, quantity)
- Handler: The actual code that runs
Field | DataType | Description |
---|---|---|
name | String | Unique name used to identify the tool (mandatory). |
description | String | Helps Copilot understand what the tool does — used for LLM decision-making (mandatory). |
timeout | Number | Timeout in milliseconds (must be a positive number between 1-15000ms). Maximum allowed value is 15000ms. |
handler | Function | The code to execute when the tool is triggered. Must return a success/error object. |
parameters | Object | JSON Schema object describing expected input parameters (optional but recommended for LLM precision). |
See a Simple Example
const tools = [
{
name: "add_item_to_cart",
description: "Add product to cart",
timeout: 15000,
parameters: {
type: "object",
properties: {
product_id: { type: "string", description: "Product ID" },
quantity: { type: "number", description: "How many" }
},
required: ["product_id", "quantity"]
},
handler: async ({ product_id, quantity }) => {
// Add items to cart
return {
success: true,
message: `Added ${quantity} of ${product_id} to cart`
};
},
},
{
name: "open_cart",
description: "Opens the user's cart screen",
timeout: 15000,
handler: () => ({
success: true,
message: "Cart opened successfully",
}),
}
];
Register your Tools
Tell Copilot about all your Tools in one go:
copilot("init", function () {
copilot.tools.add(tools);
});
Manage your Tools
You can add or remove Tools at any time:
// Add one or more tools
copilot.tools.add(toolObjectOrArray);
// Remove a tool by name
copilot.tools.remove("tool_name");
// Remove all tools
copilot.tools.removeAll();
Tool Limit
You can register up to 16 tools at once. If more are passed, only the first 16 are accepted and the rest are silently ignored.