Skip to main content
MeshAgent Agents are processes that accept input and produce output. In many cases, your agent will be powered by a LLM, but it could also just be code that performs a task. This walkthrough shows how to:
  • Create a ChatBot
  • Call it into a room
  • Interact with it from the MeshAgent Studio.

Step 1: Create an agent with ServiceHost

Let’s create a simple ChatBot that takes a system prompt (rules). To run the ChatBot we’ll use the MeshAgent ServiceHost. The ServiceHost is a lightweight HTTP server that allows you to register one or more tools or agents on their own path (e.g., /agent). The host automatically exposes each path as a webhook. When a room “makes a call” to that path, ServiceHost handles the handshake, connects the agent to the room, and forwards requests and responses between your code and the MeshAgent infrastructure.
import asyncio
from meshagent.otel import otel_config
from meshagent.api.services import ServiceHost
from meshagent.agents.chat import ChatBot
from meshagent.openai import OpenAIResponsesAdapter

# Enable OpenTelemetry logging and tracing for the agent
otel_config(service_name="chatbot")

# Create a service host
service = ServiceHost()  # optional to pass a port, MeshAgent automatically assigns an available one if none provideds

# Register an agent at a specific path
@service.path(path="/chat", identity="chatbot")
class SimpleChatbot(ChatBot):
    def __init__(self):
        super().__init__(
            name="chatbot",
            title="Simple Chatbot",
            description="A helpful chatbot for room participants",
            rules=[
                "Always respond to the user first then include a fun fact at the end of your response."
            ],
            llm_adapter=OpenAIResponsesAdapter(),
        )

# Start the service
asyncio.run(service.run())

Step 2: Call the agent into a room

meshagent setup # authenticate to MeshAgent
meshagent service run "main.py" --room=quickstart
This command will start the chatbot on an available port at the path /chat. If you are running multiple agents or tools, you can use the same ServiceHost and set different paths for each of the agents. The service run command automatically detects the different agent paths and identities (this is the recommended way to test your agents and tools). As an alternative to the service run command you can also run the service locally by running python main.py in one tab in your terminal, then from another tab you can call individual agents into the room using the meshagent call agent command. For example:
bash
meshagent setup # authenticate to meshagent
meshagent call agent --url=http://localhost:8081/agent --room=quickstart --participant-name=chatbot
In either case, the agent joins the room as participant chatbot. Once the agent joins the room, you can converse with it in MeshAgent Studio.

Step 3: Interact with the Agent in MeshAgent Studio

  1. Go to MeshAgent Studio and login
  2. Enter your room quickstart
  3. Select the agent chatbot and begin chatting!

Next Steps

  • Add custom rules or toolkits to your agent:
    • See Build a Chat Agent to learn how to add built-in MeshAgent tools (for things like presenting a UI or writing to documents), and custom tools to your chatbot.
    • TaskRunner to learn how to run agents from other agent frameworks, “agents” without an LLM, and more.
    • Tools Quickstart to learn how to build custom tools.
  • Learn more about services and containers to deploy your agent as a MeshAgent project-wide service or run it in a specific room with the Containers API.
  • Explore the broader Room Agents Client for more information on listing agents, discovering tools, invoking tools, and more.