Skip to main content
By the end of this page you have a bot that replies 🪞 <your text> in any Matrix room you invite it to.

Step 1 — Get a bot token

You need an active AgentFlow user session. Sign in at agentflow.website, open DevTools → Application → Cookies → copy the af_session value.
export AF_SESSION="..."  # from your browser cookie

curl -X POST https://bots.agentflow.website/api/v1/bots \
  -H "Cookie: af_session=$AF_SESSION" \
  -H "Content-Type: application/json" \
  -d '{"slug":"my-echo","display_name":"My Echo Bot"}'
Response (the token is shown once — store it now):
{
  "ok": true,
  "bot_token": "af_bot_d1c2b3a4e5f6...",
  "slug": "my-echo",
  "matrix_user_id": "@bot_my_echo:agentflow.website",
  "display_name": "My Echo Bot",
  "is_verified": false,
  "tier": "free",
  "rate_limit_qps": 30
}
Save the bot_token. There is no way to retrieve it later — only regenerate (lose history) or delete.

Step 2 — Invite the bot to a room

Open chat.agentflow.website. In any room → settings → PeopleInvite → paste @bot_my_echo:agentflow.website (the value from matrix_user_id above). The bot won’t reply yet — it’s just sitting in the room. Webhook setup is next.

Step 3 — Run the echo bot locally

git clone https://github.com/AgentFlowX/bot-example-echo
cd bot-example-echo
npm install

export AF_BOT_TOKEN=af_bot_d1c2b3a4e5f6...
export PORT=8080
npm start
# → [echo-bot] listening on :8080
In a second terminal, expose port 8080 to the internet:
# ngrok (or Cloudflare Tunnel, or any reverse tunnel)
ngrok http 8080
# → https://abc123.ngrok.io

Step 4 — Register the webhook

curl -X POST https://bots.agentflow.website/api/v1/setWebhook \
  -H "X-AgentFlow-Bot-Token: $AF_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://abc123.ngrok.io/", "secret":"my-secret-string"}'
The platform’s webhook delivery worker now POSTs every message in joined rooms to your URL.

Step 5 — Talk to your bot

In Element, type a message in the room you invited the bot to:
you:   hi
bot:   🪞 hi
Done. Your terminal running npm start will log each POST as the platform delivers it.

Next steps