Skip to content
Docs

How to build an AI agent

In Publicus an agent is a flow. You build it from the same nodes you use everywhere else: an Agent node does the reasoning, and the nodes you connect to it become its tools, its memory, its trigger, and its reply. This guide walks the whole loop — set up → test → monitor.

There is one runtime: the flow. A plain flow handles a message per run (the agent remembers earlier turns through memory). For agents that must pause mid-task or act proactively, build the flow around a Signal/Await loop — same engine, no special mode.

Open Agents, press New agent and choose how to start:

  • Describe it to the AI builder opens the builder in a new conversation, with a first message ready for you to send. It asks who the agent is for, where it talks and what it may do on its own, then sets it up with you from the template that fits.
  • Customer agent: your customers talk to it. It answers from what you give it, changes only what you allow, and keeps within a budget per conversation.
  • Team assistant: your colleagues talk to it. It knows what the team shares, and keeps what each person tells it for that person.
  • Personal assistant: it works for you alone. See A personal assistant.
The Agents page: New agent at the top, and a card per agent saying whether it works, when it last ran and where people reach it, with Set up and Connect a channel, plus Open chat on agents that have a chat and Monitor on agents that have a conversation
The Agents page: New agent at the top, and a card per agent saying whether it works, when it last ran and where people reach it, with Set up and Connect a channel, plus Open chat on agents that have a chat and Monitor on agents that have a conversation
New agent with four ways to start: Describe it to the AI builder, Customer agent, Team assistant and Personal assistant
New agent with four ways to start: Describe it to the AI builder, Customer agent, Team assistant and Personal assistant

A template opens on a setup list that says what is left and links to where you do it; reopen it with Set up on the agent’s card. The setup list also opens the agent’s flow, and so does the agent’s name on its card. When nothing is left, press Open chat and talk to it the way its users would.

An agent's setup list naming what is left to do, with a Go there link, above Connect a channel, Open the agent and Open chat
An agent's setup list naming what is left to do, with a Go there link, above Connect a channel, Open the agent and Open chat

You get a ready flow: a chat, an agent that only reads, a conversation memory, a budget per conversation, and a Toolbox with one entry left to fill: the knowledge it answers from.

To let customers reach it from a chat app, press Connect a channel on its card: paste your Telegram bot’s token (from @BotFather), or pick a Discord or Slack connection the workspace already has. Its messages then start the agent, and the agent answers in the chat. The setup list says whether each channel reaches it; one added after you published the agent needs publishing again.

Connect a channel, with Where set to a Telegram bot of your own and a Bot token field
Connect a channel, with Where set to a Telegram bot of your own and a Bot token field

To let customers email it, choose Email and pick a mailbox under Services → Mailboxes that the platform can send from: a Publicus inbox, a connected Microsoft or Google mailbox, or one with SMTP settings. For people to write to the agent at a Publicus inbox, switch on its New mail setting. The agent then answers each email as a reply in its thread, from the mailbox it arrived in, and remembers the thread as one conversation. Choose whether it sends its answers or saves them as drafts for someone to check and send (drafts need a Microsoft or Google mailbox). Two steps appear after the agent on its canvas: Only for email, which lets only an email through (not a chat, and not an automatic reply such as an out-of-office), and Answer by email, the reply itself, whose wording you can change.

Connect a channel with Where set to Email: a mailbox you have, the workspace's Publicus inbox picked, and Its answers set to Send them rather than Save them as drafts
Connect a channel with Where set to Email: a mailbox you have, the workspace's Publicus inbox picked, and Its answers set to Send them rather than Save them as drafts
A team assistant's canvas where an Email: Operations inbox trigger and a Chat start the agent, and Only for email and Answer by email follow it
A team assistant's canvas where an Email: Operations inbox trigger and a Chat start the agent, and Only for email and Answer by email follow it

Everything it starts with is an ordinary setting you can change, which the rest of this guide explains.

You get the same shape for colleagues: a chat, an agent that asks before it changes anything, a conversation memory per person, a Toolbox with one knowledge entry to fill, and a Team memory.

Setting up Dispatch team assistant: a warning that the Team tools entry does not say which knowledge it gives yet, with Go there, and checks for the team memory, the chat and the email channel
Setting up Dispatch team assistant: a warning that the Team tools entry does not say which knowledge it gives yet, with Go there, and checks for the team memory, the chat and the email channel
  • What holds for everyone goes in its brief. On the Memory page, press Write a brief and use the tag brief/team. The assistant can also propose additions there for you to keep or drop.

    Keep this brief, showing the assistant's proposed brief as lines struck out and their replacements added, with Keep and Cancel
    Keep this brief, showing the assistant's proposed brief as lines struck out and their replacements added, with Keep and Cancel
  • What a colleague tells it is kept for that colleague, and recalled only in that colleague’s conversations. It knows who is writing in the app’s chat, Telegram, Slack, Discord and email.

  • Give it one channel. A colleague who writes from Slack and from Telegram is two people to it.

If you ran an assistant on OpenClaw, the builder can set it up here from its workspace. Zip the workspace’s text files and attach the zip in the builder. In a new conversation, Bring an agent from OpenClaw or Hermes words the request and opens the file picker for you:

Terminal window
cd ~/.openclaw && zip -r openclaw.zip workspace openclaw.json -i '*.md' '*.json'

A file can be up to 8 MB, which a workspace’s text files rarely reach; a whole folder with its scripts and history usually does. A .tar.gz or .tar works as well as a zip. To bring scheduled jobs along, add openclaw automations list --all --json > automations.json to the zip. The keys in openclaw.json are in the zip already; to bring the ones in your .env too, zip it as well: zip -r openclaw.zip workspace openclaw.json .env -i '*.md' '*.json' '*.env'.

Publicus cleans the zip before the builder sees it. It keeps the persona, rules, memory, skills, notes and scheduled jobs as one document, or as a few parts when the workspace is long, so that the builder reads each one whole. It leaves out credential files, and every key or token in the text is replaced with [redacted]. The builder then starts the template that fits and carries the rest over: the assistant itself proposes what belongs in its brief and records what it should remember, and you keep or drop each proposal on the Memory page. Your keys come along only if you ask, as Bring your keys along describes.

If you ran an assistant on Hermes Agent, the builder can set it up here from its home folder. Zip the files the import reads and attach the zip in the builder:

Terminal window
cd ~/.hermes && zip -r hermes.zip SOUL.md profile.yaml config.yaml memories skills cron/jobs.json

For a named profile, run the same command in ~/.hermes/profiles/<name>, or attach the .tar.gz that hermes profile export <name> writes. Each profile is its own assistant, so attach one archive per profile. zip warns about any file your home does not have, and that is fine. To bring your keys along, add .env auth.json to the command.

Publicus cleans the zip before the builder sees it. It keeps the persona, the memory, the scheduled jobs, the names of your settings and the skills you or your assistant wrote. It leaves out your keys and tokens, your past conversations, and the skills that ship with Hermes. The builder then starts the template that fits and carries the rest over the same way as an OpenClaw import: the assistant proposes its own brief and memory, and you keep or drop each proposal on the Memory page. Your keys come along only if you ask, as below.

When the archive holds keys (a .env, the keys in openclaw.json, or the API keys Hermes keeps in auth.json or its config.yaml), the builder lists them under the attached file with Move its keys into this workspace. Tick it, and when you send the message Publicus puts each key straight into the workspace’s vault:

  • A key for a service Publicus connects with a key alone, such as GitHub, Notion or Linear, becomes a connection.
  • A Telegram, Discord or Slack bot token becomes a secret, which you pick when you connect the channel.
  • Any other key becomes a secret.

The builder sees each key’s name and where it went, never its value. Nothing already in the workspace is replaced. Which keys, and where each would go lists them before you send.

A key for an AI model provider, such as OpenAI or Anthropic, is kept as a secret unless you also tick Pay this workspace’s model calls with those model keys. That makes it the key every call to that provider from this workspace is billed to, your colleagues’ calls included, so leave it off in a workspace you share. You can make it the workspace’s key later under AI models.

Leave the box unticked and the keys stay behind: the builder asks for each one it needs, on a card.

Sign-ins such as Gmail and Google Calendar never move, because your old assistant used them through your own Google app. The builder helps you connect them again here.

For an assistant that works for you alone, open Agents, press New agent and choose Personal assistant. A workspace holds one: when it has one already, the choice says so and opens its setup instead. You get three flows that share a table and a few settings:

  • Assistant talks to you in Telegram and in the app’s chat. It can look things up, and it asks you before it changes anything.
  • Assistant heartbeat wakes every 15 minutes from 07:00 to 23:00 and works through your Standing orders. It messages you only when an order has something to report.
  • Assistant inbox sorts the mail that reaches your mailbox. For a mail worth answering it sends you the reply it would write, in Telegram, for you to edit and send or skip. A reply you have not answered within two days is kept as a draft in your mailbox.

The setup list walks you through the rest:

  1. Use a workspace only you are in. Every member of a workspace can read what its assistant reads and remembers.

  2. On the assistant’s card, press Connect a channel, choose Telegram and paste your own bot’s token (from @BotFather).

  3. Turn on Approvals for that bot, so you can answer the assistant’s questions with a button in Telegram.

  4. Link your Telegram account with Use from a chat app on the AI builder page. A button you press counts only from a linked account.

  5. Press Fill in. It tells the assistant your Telegram chat and your time zone, and lets the heartbeat and the inbox write to you through your bot.

  6. Set your workspace’s time zone on the Schedules page if you have not.

  7. Choose the mailbox the inbox reads. Use a connected Microsoft or Google mailbox: only those can keep drafts.

  8. Tell it who you are in its brief: on the Memory page, press Write a brief and use the tag brief/assistant. You can also tell the assistant and keep what it proposes there.

    Write a brief with a Tag field whose placeholder reads brief/assistant, and a Brief field for who the agent works for and the rules it keeps
    Write a brief with a Tag field whose placeholder reads brief/assistant, and a Brief field for who the agent works for and the rules it keeps
  9. Switch on the heartbeat’s and the inbox’s triggers when you are ready.

Standing orders are rows in the Standing orders table. Each has a title and instructions. It runs either every so many minutes (every_minutes) or once a day at a time of yours (at_time, such as 07:30). Fill in neither and it runs once, which makes it a reminder. Two orders come with it: a heartbeat checklist every 30 minutes and a morning brief at 07:30. The assistant can add orders itself when you ask it to, after you approve.

To pause the heartbeat, set assistant_paused to 1 under Key-value.

Create a flow and add an Agent node (the picker groups it under AI). Configure:

  • Model: your LLM (OpenAI, Anthropic, Gemini, Ollama, Mistral, Groq, xAI). Picking a model sets its Provider; the form asks for the provider only when the model does not say which.
  • Credential: leave it empty to pay with the workspace’s key for the provider, set on the AI models page. To pay with another key, pick a secret holding it, or a saved connection.
  • Instructions: who the agent is and how it should behave.
  • Message: the user’s message, usually from the trigger: {{ $start->payload->message }}.

Max steps and Approval mode follow. Files to read, the shape of the answer and the budgets are under More settings, and the options for a chat app’s bot under Chat app; both open when you click them.

The agent emits its reply under content.

The Agent node's settings: Provider, Model, Credential, Instructions, Message, Max steps and Approval mode, with the Chat app, More settings and Advanced sections closed below them
The Agent node's settings: Provider, Model, Credential, Instructions, Message, Max steps and Approval mode, with the Chat app, More settings and Advanced sections closed below them

2. Give it tools (your APIs and resources)

Section titled “2. Give it tools (your APIs and resources)”

An agent is only as useful as what it can do. Any node that implements the tool contract can be attached to the agent’s TOOL handle, and the model calls it when it decides to. Useful tools:

  • Rest / Operation and OpenApi / Operation — call your business APIs.

  • Database / Select and the storage nodes (KeyValueStore, TableStore) — read and write your data.

    The Add a node picker searched for Database, listing Database Execute, Database Insert and Database Select under Storage
    The Add a node picker searched for Database, listing Database Execute, Database Insert and Database Select under Storage
  • Rag / VectorStore / Query — answer from a knowledge base.

  • Channel / * — let the agent send a message itself.

Wiring a tool: connect the tool node’s OUTPUT to the agent’s TOOL handle (the violet wrench at the left of the Agent node’s bottom edge). To let the model fill a tool’s parameters, use a {$fromAI:name:description:type} directive in that node’s field — the model supplies the value at call time.

An agent flow where a Toolbox is wired to the Agent's wrench handle and a Chat Thread to its memory handle, beside the funnel and model handles
An agent flow where a Toolbox is wired to the Agent's wrench handle and a Chat Thread to its memory handle, beside the funnel and model handles

Or pick them from a list: add a Toolbox node, wire it to the agent’s TOOL handle, and add a row per thing the workspace already has. One Toolbox holds as many as you like:

  • A flow — the agent runs it as a tool and reads what it returns.
  • An MCP server — all of its tools, or only the ones you choose.
  • An API — an OpenAPI, SOAP, GraphQL or OData schema you imported, all of it or chosen operations, signed in with a connection or a secret.
  • Knowledge — a knowledge base the agent can search.
  • A table — the agent can find rows; switch on May change things to let it add and change them too.

Each row has When to use it, a sentence for the agent, and Ask before it runs. For a flow, the agent reads that sentence after the flow’s own Description, so describe what the flow does on the flow and say here when this agent should use it. May change things decides whether a Read-only agent may use that row’s tools to change something (see Keep a public agent small). Running a flow counts as a change.

The Toolbox node's settings, with Add a tool for a flow, an MCP server, an API, knowledge to search or a table
The Toolbox node's settings, with Add a tool for a flow, an MCP server, an API, knowledge to search or a table

Add a Chat Thread node to the canvas (find it under AI in the node picker) and connect its output to the agent’s MEMORY handle (the stacked discs on the Agent node’s bottom edge, between the wrench and the chip). This makes conversation history a visible, composable part of the flow.

The Add a node picker filtered to Chat Thread, listing it under AI as conversation memory for the agent's Memory handle
The Add a node picker filtered to Chat Thread, listing it under AI as conversation memory for the agent's Memory handle

Configure the Chat Thread node with a stable per-conversation identity:

  • Channel: required. The channel the conversation comes from (discord, slack, telegram, etc.), or {{ $start->channel }} for an agent behind a chat app.
  • Conversation: a unique key for this conversation, e.g. {{ $start->threadId }} from a chat trigger.
  • User: optional. Scope the thread further to a specific user.
The Chat Thread node's settings: Channel, Conversation, User and Title, then its write policy, recency window and Carry forward
The Chat Thread node's settings: Channel, Conversation, User and Title, then its write policy, recency window and Carry forward

Use stable values so each turn of the same conversation loads the same history. Conversation history is stored in a chat thread you can inspect later.

Chat Thread is not the only memory node. The MEMORY handle also accepts a Governed node (durable facts, constraints, and decisions, recalled by relevance each turn and reviewable by a human) and a Summary node (rolling per-turn summaries recalled into the system prompt). You can attach more than one. See memory for how each layer works.

How the flow starts:

  • Webhook or Webhook / Chat — start on an inbound HTTP request / chat message.
  • Webhook / Telegram — a Telegram bot message.
  • Schedule — run the agent on a cron (for proactive or batch work).

An agent connected to a chat app with Connect a channel, or behind a Discord or Slack bot under Chat apps, needs no step for this: the bot posts the answer in the conversation the message came from. Otherwise, add a Channel / * send node and wire Agent → Channel/*, setting the message to {{ $prev->content }}. See connecting an agent to a chat channel for Slack, Discord, Teams, Telegram, and WhatsApp.

Click Run by hand on the flow page. When the flow asks for input, Publicus builds a form from it, so you can run the agent without crafting a request by hand. A flow that a trigger starts and that asks for nothing offers its start data under Start data instead, filled in with an example of what the trigger sends, for you to change. Watch the canvas: the Agent node streams its tokens live, and node states update as the run progresses.

Run flow with a field for each input the flow asks for: Pickup address, Pallets and Pickup date
Run flow with a field for each input the flow asks for: Pickup address, Pallets and Pickup date
Run flow for a flow that only Start starts and that asks for nothing, saying the run starts with no data
Run flow for a flow that only Start starts and that asks for nothing, saying the run starts with no data

Start on the agent’s card under Agents. Its badge says whether the agent works, in the words the Flows list uses, such as Working, Failing or Quiet; hover over it to see why. Under the agent’s name you see when it last ran and how many runs it has, and the count opens those runs.

The card also lists where people reach the agent: Chat in Publicus, and each Discord or Slack channel, mailbox and Telegram bot you connected. (off) follows one whose trigger is switched off, so it does not reach the agent until you switch it on. A channel or mailbox that has stopped working, or has heard nothing for two weeks, carries a badge saying so; select its name to open its page. A chat block on a portal page is not listed, but its conversations count in the agent’s runs.

Monitor opens the agent’s own conversations. It appears once the agent has had one.

For a single run, read its run report: open the run from the Runs panel beside the flow’s canvas, or from the card’s runs count. The report shows a per-node timeline with each agent turn nested under the Agent node, tokens streaming live while the run is active, token totals, previews of every tool call, and what memory the agent recalled and recorded. Pending human approvals can be decided with Approve / Deny directly on the report, and a Re-run action starts the flow again with the same input.

A run report for an agent: the verdict with token totals, then the Agent's timeline entry with its model, tools offered, memory, each turn's tool call and tokens, and its output
A run report for an agent: the verdict with token totals, then the Agent's timeline entry with its model, tools offered, memory, each turn's tool call and tokens, and its output
The Memory panel on an agent's timeline entry, listing the earlier messages it recalled with their roles
The Memory panel on an agent's timeline entry, listing the earlier messages it recalled with their roles
A waiting run with a pending approval badge, its Agent entry showing the tool call and an Approvals row with Approve and Deny
A waiting run with a pending approval badge, its Agent entry showing the tool call and an Approvals row with Approve and Deny

For the conversation itself, open the agent’s chat thread to review the transcript — every message with its role, content, token usage (in/out), and any tool calls — plus a running total of tokens used. This is where you confirm the agent recalled context, called the right tools, and answered correctly.

The Tool calls window of a chat thread message, showing the raw call to a subagent with its arguments and the result it returned
The Tool calls window of a chat thread message, showing the raw call to a subagent with its arguments and the result it returned

8. (Optional) Expose it to other AI clients

Section titled “8. (Optional) Expose it to other AI clients”

Mark the flow as an MCP tool so external AI clients can invoke your agent as a tool.

An agent anyone can write to, such as a support bot on Telegram, needs limits a person at a keyboard does not:

  • Read-only, with only the changes you chose. See Let a Read-only agent make one kind of change.

    The Agent's Approval mode picker and its May change things list, which names the tools a Read-only agent may still use to change something
    The Agent's Approval mode picker and its May change things list, which names the tools a Read-only agent may still use to change something
  • Most tokens one conversation may use per day, under More settings. Past it, the agent’s next turn in that conversation gets your Reply when the budget is spent instead of a model call. It needs a chat memory node, which is what tells one conversation from another. Write the reply in your customers’ language; the default is a short English sentence.

    The Agent's limits: most tokens and minutes one turn may use, most tokens one conversation may use per day, and the reply when the budget is spent
    The Agent's limits: most tokens and minutes one turn may use, most tokens one conversation may use per day, and the reply when the budget is spent
  • The workspace’s daily AI token limit applies to every agent. A conversation past it gets the same reply; an agent with no conversation (a scheduled or pipeline run) fails its step and names the limit.

Both limits are checked before a turn starts, never halfway: a turn already under way, and an agent a running flow calls as a tool, always finishes.