Tool Chaining
Hunch supports intelligent multi-tool chaining, allowing the AI to automatically execute multiple tools in sequence based on user intent, with results from one tool flowing into the next.
How Tool Chaining Works
When a user request requires multiple actions, the AI can:
- Detect chaining intent - Recognize when multiple actions are needed
- Execute sequentially - Run tools in the correct order
- Pass results - Use output from one tool as input to the next
- Synthesize response - Provide a unified response with all results
Examples
Shopping Flow
User: "Find a red sweater and add it to my cart"
↓
AI: Executes search_products → add_to_cart
↓
Result: "Found the red sweater! I've added it to your cart."
Booking Flow
User: "Check if you have the blue shirt in size M, and if so, book an appointment"
↓
AI: Executes check_inventory → book_calendly_appointment
↓
Result: "Yes, the blue shirt is available! I've booked your appointment."
Newsletter + Lead
User: "Subscribe me to the newsletter and notify your team"
↓
AI: Executes subscribe_newsletter → send_lead_notification
↓
Result: "You're subscribed! Our team has been notified."
Context Sharing
Tools automatically share context through the Tool State Manager:
Cart State
- Products added to cart persist across tools
- Cart can be checked at any point
- Checkout tool can access full cart contents
Previous Results
- Each tool's result is stored
- Subsequent tools can reference prior results
- Context is preserved for the session
User Context
- Email, name, and ID available to all tools
- Tools can personalize based on user data
- Context updates as user provides information
Supported Chains
E-commerce
| Chain | Tools | Description |
|---|---|---|
| Search → Add to Cart | search_products, add_to_cart | Find and purchase |
| Add → Checkout | add_to_cart, get_cart, checkout | Complete purchase |
| Inventory → Book | check_shopify_inventory, book_calendly_appointment | Check availability and book |
Scheduling
| Chain | Tools | Description |
|---|---|---|
| Check → Book | check_calendly_availability, book_calendly_appointment | Find and book |
| Search → Schedule | search_products, book_calendly_appointment | Product inquiry to booking |
Lead Capture
| Chain | Tools | Description |
|---|---|---|
| Subscribe → Notify | subscribe_newsletter, send_lead_notification | Newsletter with alert |
| Contact → CRM | submit_contact_form, create_crm_lead | Form submission pipeline |
Implementation
Frontend Integration
The embed widget automatically handles tool chaining - no additional configuration needed.
API Integration
For custom implementations, use the /llm/tool-chain endpoint:
POST /api/llm/tool-chain
{
"website_id": "abc123",
"session_id": "session_xyz",
"messages": [
{ "role": "user", "content": "Find red sweater and add to cart" }
],
"tools": [...],
"tool_results": [
{ "toolName": "search_products", "result": { "products": [...] } }
],
"continue_chain": true
}
Configuration
Chain Length Limits
- Default: 5 tools per chain
- Configurable per plan
- Prevents infinite loops
Context Injection
Results are automatically injected into subsequent tools.
Critical Tool Handling
If a critical tool (checkout, payment, booking) fails, the chain stops.
Best Practices
- Enable relevant tools - More tools = better chaining
- Test flows - Verify chains work for common user journeys
- Monitor usage - Track which chains are most popular
- Handle failures - Provide fallback options when chains fail