What You’ll Build
In this guide, you’ll create a complete AI persona with tool calling capabilities. By the end, you’ll have:- A knowledge base with uploaded documents
- Multiple tools (knowledge, webhook, and client)
- A working persona that can search documents, call APIs, and trigger client actions
This guide takes approximately 15 minutes to complete. We’ll use both the Anam Lab UI and API for a complete understanding.
Prerequisites
Before starting, ensure you have:- An Anam account (sign up at anam.ai)
- An API key (create one at
/api-keys) - Basic familiarity with REST APIs
- (Optional) Node.js or Python for testing
Step 1: Create a Knowledge Folder
Knowledge folders organize your documents for semantic search. Let’s create one for product documentation.- UI
- API
-
Navigate to the Knowledge Base page at
/knowledge - Click Create Folder
-
Enter the following details:
- Name: Product Documentation
- Description: Technical guides and product information
- Click Create
Your folder is created with a unique ID. Note this ID for later use.
Step 2: Upload Documents
Upload documents to make them searchable. We’ll use a PDF user guide as an example.- UI
- API
- On the Knowledge Base page, click into your Product Documentation folder
- Click Upload Documents
- Drag and drop your PDF or click to browse
- Click Upload
- Wait for processing to complete (~30 seconds)
The document status changes from PROCESSING to READY. It’s now searchable!
Step 3: Create a Session with Tools
Ephemeral personas support two ways to configure tools at runtime:- Reference pre-created tools using
toolIds- Best for reusing tools across different sessions or personas - Define tools inline using
toolsarray - Best for session-specific or dynamic tool configurations
- Using toolIds (Reusable)
- Inline tools (Dynamic)
First, create reusable tools via the API. These can be used across multiple sessions and personas.
Reference tools by ID in session
Create a Knowledge Tool
Create a Knowledge Tool
Create a Webhook Tool
Create a Webhook Tool
Create a Client Tool
Create a Client Tool
This approach lets you manage tools centrally and reuse them across multiple sessions and personas.
Step 4: Initialize SDK and Handle Events
Testing Your Tools
Let’s test the complete setup with example conversations:Testing Knowledge Tool
User: “How do I install the product?” Expected flow:- LLM recognizes this as a technical question
- Invokes
search_product_docstool - Retrieves relevant chunks from your user guide
- Responds with accurate installation steps
Testing Webhook Tool
User: “What’s the status of my order ORD-12345?” Expected flow:- LLM extracts order ID
ORD-12345 - Calls
check_order_statuswebhook withorderId: "ORD-12345" - Receives response from your API
- Tells user the current order status
Testing Client Tool
User: “Show me more details about the premium plan” Expected flow:- LLM identifies product name “premium plan”
- Calls
open_product_pageclient tool - SDK emits
TOOL_CALLevent that your listener handles - Navigation happens:
window.location.href = '/products/premium-plan'
Troubleshooting
Knowledge tool returns no results
Knowledge tool returns no results
Possible causes:
- Document still processing (check status)
- Query doesn’t match document content
- Folder ID incorrect
- Wait for document status to be READY
- Test query with debug modal (
Ctrl+Shift+Kon knowledge page) - Verify folder ID in tool configuration
Webhook tool times out
Webhook tool times out
Possible causes:
- External API is slow (>60s timeout)
- Network connectivity issues
- Invalid endpoint URL
- Check endpoint URL is correct
- Test endpoint independently with curl
- Ensure API returns response within 60 seconds
- Check authentication headers are valid
Client tool event not received
Client tool event not received
Possible causes:
- SDK client not properly initialized
- Event listener not registered before session starts
- Tool name mismatch
- Verify SDK client is initialized with valid session token
- Add event listener using
client.addListener(AnamEvent.TOOL_CALL, handler)before callingstreamToVideoElement - Match tool name exactly in your handler (case-sensitive)
- Check browser console for any SDK initialization errors

