All Tools Overview
The Leclerk chatbot system uses 21 specialized tools to handle customer interactions, manage orders, and provide restaurant services. Tools are the bridge between natural language conversations and concrete business operations.Tool Architecture
All tools inherit fromBaseTool and are managed by ToolRegistry. Each tool implements:
name: Unique identifierdefinition: JSON schema for the LLMprompt_definition: Instructions for when/how to useexecute: Async method that performs the operation
Tool Categories
Order Management (5 tools)
update_order_draft
The central tool for managing order state. Handles items, delivery details, payment methods, and all order modifications. Key Features:- Add/modify items with SKU IDs and options
- Set delivery or collection service type
- Apply promo codes and deals
- Configure payment methods
- Schedule orders for specific times
menu_lookup
Powerful menu search and browsing with 7 query types:browse_categories- Minimal token usage overviewsearch_skus- Fuzzy search for items and dealslist_categories- Full category detailslist_skus- Filter and list itemsget_sku_details- Detailed item informationlist_deals- Available promotionsget_deal_details- Deal specifications
- Supports batch queries for multiple items
- Use field selection to reduce token usage
- Organization mode requires location_id parameter
check_address
Validates delivery addresses and finds serviceable locations. Behavior by Mode:- Location Mode: Simple validation against delivery zone
- Organization Mode: Returns best location (lowest fee/shortest distance)
switch_location when address is validated in organization mode.
send_order_form
Sends WhatsApp interactive flow for visual menu browsing. Requirements:- Location must have WhatsApp flows enabled
- In organization mode, location must be set first
- Customer receives native WhatsApp form interface
query_live_order_status
Real-time status for active orders with multiple query types:status- Basic order statuspayment- Payment confirmationdelivery- Full delivery detailstracking- Tracking URLdriver- Courier informationcollection- Pickup detailstiming- Time estimatesall- Complete information
Customer Information (3 tools)
get_customer_previous_orders
Retrieves order history for personalization:- Previous orders with items
- Favorite products (frequently ordered)
- Order statistics and patterns
- Automatically included in context at conversation start
get_current_time
Gets current time in specified timezone.- Essential before scheduling orders or messages
- Default timezone: Europe/Zurich
- Returns ISO 8601 formatted datetime
get_store_information
Fetches restaurant configuration and details:- Basic info (name, ID)
- Location and address
- Opening hours by service type
- Payment methods available
- Delivery settings
- Average preparation time
Messaging & Engagement (5 tools)
schedule_message
Schedules WhatsApp messages up to 24 hours ahead. Message Types:permanent- Always sent at scheduled timeuntil_next_message- Cancelled if customer messages first
get_current_time first for accurate scheduling.
cancel_scheduled_message
Cancels scheduled messages using ID from creation.list_scheduled_messages
Shows all pending scheduled messages for the conversation.react_to_message
Adds emoji reactions to acknowledge customer messages.- Enhances conversational experience
- Use sparingly and appropriately
generate_fortune_wheel_link
Creates promotional game links for customer engagement.- Location-specific promotions
- One-time play per customer
- Secure phone number hashing
Customer Management (3 tools)
change_customer_language
Updates UI language preference. Supported Languages:- French (fr)
- English (en)
- German (de)
- Italian (it)
- Spanish (es)
manage_customer_memory
Persistent storage for customer preferences. Operations:get- Retrieve stored informationset- Store new preferencesdelete- Remove memory
location- Restaurant-specificbusinessOrganization- Chain-wide
- Dietary restrictions
- Delivery preferences
- Special instructions
register_feedback
Structured feedback collection with scoring:general_score(required) - Overall satisfactionfood_score- Food qualitydelivery_score- Delivery serviceordering_experience_score- Ordering process
Multi-location Support (2 tools)
switch_location
Changes active location in organization mode.- Resets current order draft
- Updates menu and settings
- Only available in organization mode
organization_location_query
Information about other organization locations. Query Types:list_all- All locations overviewget_location_details- Specific location infocheck_availability- Operating status
Internal Tools (2 tools)
think
Internal reasoning for complex logic. When to Use:- Validation error troubleshooting
- Complex orders (5+ items)
- Ambiguous customer requests
- Menu searches with specific criteria
report
Escalates issues to support team. Priority Levels:- P0 - Critical: System down
- P1 - High: Major feature broken
- P2 - Medium: Non-critical bug
- P3 - Low: Minor issues
- P4 - Trivial: Cosmetic issues
Organization vs Location Mode
The system operates differently based on context:Location Mode
- Single restaurant location
- Direct menu access
- Simple address validation
- Straightforward tool behavior
Organization Mode
- Multiple locations in chain
- Requires location selection first
check_addressfinds best location- Tools need location_id parameter
switch_locationavailable
Payment Flow Integration
Three payment scenarios handled through tools:-
RegisterWithoutPayment
- Store handles payment directly
- Order registered without payment processing
-
InstantPayment
- Saved card on file
- Immediate charge upon confirmation
- Shows card details (brand, last 4 digits)
-
CheckoutPayment
- One-time payment
- Payment link sent to customer
- Secure checkout process
-
noPaymentMethod
- Card setup required
- Setup URL sent automatically
- Order held until payment configured
Common Tool Patterns
Batch Operations
Several tools support batch queries for performance:Field Selection
Reduce token usage by requesting only needed fields:Error Response Pattern
All tools return consistent error structures:Best Practices
Performance Optimization
- Batch related operations - Multiple queries in single call
- Use minimal fields - Only request needed data
- Cache when appropriate - Don’t repeat identical queries
- Think tool sparingly - Adds significant latency
Reliability
- Validate early - Check address before building order
- Handle errors gracefully - Provide alternatives
- Report issues promptly - Use report tool for problems
- Check prerequisites - Ensure required data exists
Customer Experience
- Be proactive - Validate addresses early
- Provide feedback - Acknowledge with reactions
- Personalize - Use order history and memory
- Stay organized - Use proper tool sequencing
Organization Mode Specifics
- Set location first - Required for most operations
- Include location_id - In tool parameters when needed
- Handle switching - Update context after location changes
- Check capabilities - Not all locations have same features
Tool Dependencies
Some tools work together in sequences:Integration Points
- Nexus API: Backend for all operations
- WhatsApp Business API: Messaging and flows
- Payment Providers: Card processing
- Langfuse: Observability and tracing
- Linear: Issue tracking
- Discord: Team notifications
Monitoring & Observability
All tools use Langfuse@observe decorators for:
- Execution tracing
- Performance metrics
- Error tracking
- Usage analytics
Security Considerations
- Phone numbers hashed in fortune wheel
- Payment data handled by secure endpoints
- Customer memory sanitized for sensitive data
- Location-scoped vs organization-scoped data separation