Skip to main content
Take your support bot to the next level by adding Agentic Loops that can search your knowledge base, look up orders, check inventory, and provide responses grounded in real data. This intermediate guide builds on the basic support bot with tool-calling capabilities.

What You’ll Learn

By the end of this guide, you’ll be able to:
  • Understand how Agentic Loops enhance bot responses
  • Connect MCP servers to provide tools for your bot
  • Ground AI responses in real-time data
  • Handle complex support queries that require data lookups
  • Combine multiple tools for sophisticated workflows

Prerequisites

Before starting, you should have:
  • Completed the Basic Support Bot guide
  • A working bot connected to at least one channel
  • Basic understanding of APIs and webhooks
  • Access to data sources you want the bot to query (optional)

Understanding Agentic Loops

Regular bots send messages to an AI integration and return the response. This works well for general questions, but falls short when you need to:
  • Search a knowledge base for specific information
  • Look up order status in a database
  • Check real-time inventory levels
  • Fetch current weather or other external data
  • Perform calculations or data transformations
Agentic Loops solve this by giving your AI access to tools (MCP servers) that can interact with external systems. The AI can decide when to use these tools, call them automatically, and incorporate the results into its response.

How It Works

Step 1: Create an Agentic Loop

1

Navigate to Agentic Loops

From your dashboard, click Agentic Loops in the sidebar.
2

Create New Loop

Click Create Agentic Loop.
Agentic loops list

Agentic Loops dashboard

3

Configure the Loop

Enter the following details:
  • Name: “Support Bot Knowledge Search”
  • Description: “Searches knowledge base for accurate support answers”
  • Max Iterations: 10 (allow up to 10 reasoning steps)
Create loop form

Create agentic loop form

4

Write System Prompt

Define the agent’s role and available tools:
5

Add Initial User Message

This message starts the loop. You can leave it blank if the bot will provide the message dynamically:
This placeholder will be replaced with the actual user question when triggered from your bot.
6

Save the Loop

Click Create to save your agentic loop.

Step 2: Add MCP Servers

MCP servers provide tools that your agentic loop can use. Let’s add servers for common support scenarios.
1

Add HTTP Client Server

The HTTP Client MCP server allows the agent to make API calls.
  1. In your agentic loop, go to the MCP Servers tab
  2. Click Add MCP Server
  3. Select HTTP Client
  4. Configure access:
    • Allow all domains: Enable if your APIs are on different domains
    • Allowed domains: Or specify specific domains (e.g., api.yourcompany.com)
  5. Click Add
MCP server setup

MCP server configuration

2

Add Time Server (Optional)

If your bot needs to know the current time for date-based queries:
  1. Click Add MCP Server
  2. Select Time
  3. Set timezone: America/New_York (or your timezone)
  4. Click Add
3

Add Google Maps Server (Optional)

For location-based support (store locator, service areas):
  1. Click Add MCP Server
  2. Select Google Maps
  3. Enter your Google Maps API key
  4. Click Add
The agent will automatically see available tools from all connected MCP servers and decide when to use them based on the user’s question.

Step 3: Connect Loop to Your Bot

Now we need to modify your bot’s integration to use the agentic loop.

Option A: Update Existing Integration

Modify your webhook integration to call the agentic loop:

Option B: Use Agentic Loop Directly

Set the agentic loop as your bot’s integration:
1

Get Loop Webhook URL

Copy the webhook URL from your agentic loop settings:
2

Create New Integration

In your bot’s Integrations tab:
  • Name: “Agentic Support Loop”
  • Webhook URL: Paste the loop webhook URL
  • Headers: Add authentication
3

Set as Primary

Set this integration’s weight to 100 to use it for all messages.
To search your knowledge base, you’ll need an API endpoint that the agent can call.

Example: Search API

Update System Prompt

Tell the agent how to use this API:

Step 5: Test the Grounded Bot

1

Send a Knowledge Base Question

Ask something that requires searching your documentation:
2

Observe the Agent Working

The agentic loop will:
  1. Receive the question
  2. Decide it needs to search the knowledge base
  3. Call the HTTP tool to search
  4. Receive search results
  5. Format a response with accurate information
  6. Return the answer to the user
3

Check the Logs

View the loop execution logs to see:
  • Number of iterations used
  • Which tools were called
  • API responses received
  • Agent’s reasoning process
Execution logs

Loop execution logs

4

Verify Accuracy

Confirm the response includes:
  • Accurate information from your knowledge base
  • Links to relevant documentation
  • No hallucinated or made-up information

Advanced Patterns

Pattern 1: Multi-Step Order Lookup

Handle complex queries that require multiple API calls:

Pattern 2: Inventory Check

Check product availability before answering:

Pattern 3: Context-Aware Support

Use conversation history to provide better answers:

API Examples

For complete API documentation, see the OpenAPI specification.

Best Practices

Clear Tool Instructions

Document exactly how to use each tool in the system prompt

Error Handling

Tell the agent what to do when API calls fail

Limit Iterations

Set appropriate max iterations to prevent infinite loops

Monitor Usage

Track which tools are used most often and optimize

System Prompt Tips

Be Explicit About APIs:
Define Error Responses:
Set Response Format:

Troubleshooting

Loop times out before completing

Cause: Too many iterations needed or slow API calls Solutions:
  • Increase max iterations
  • Optimize your API endpoints for speed
  • Simplify the agent’s task
  • Cache frequently accessed data

Agent doesn’t use tools

Cause: System prompt doesn’t clearly explain when/how to use tools Solutions:
  • Add explicit instructions about tool usage
  • Provide examples in the system prompt
  • Test with questions that definitely require tool usage
  • Check MCP server logs for errors

Responses are inaccurate

Cause: Agent may be hallucinating or misinterpreting API responses Solutions:
  • Tell agent to only use information from API responses
  • Add explicit instruction to say “I don’t know” when unsure
  • Format API responses more clearly
  • Review execution logs to see what data agent received

API calls fail

Cause: Authentication issues, rate limits, or incorrect endpoints Solutions:
  • Verify API credentials are correct
  • Check allowed domains in MCP server settings
  • Review API logs for specific errors
  • Add retry logic for transient failures

Next Steps

Build a Personal Assistant

Use multiple MCP servers for advanced workflows

Deploy to Multiple Channels

Use the same grounded bot across platforms

MCP Server Reference

Learn about all available MCP servers

Agentic Loops Documentation

Deep dive into agentic loop features