Chatbots & Telegram
FleetQ lets you deploy AI-powered chatbots that interact with users via embeddable web widgets or Telegram. Every chatbot is backed by a FleetQ Agent, inheriting its model, skills, tools, and prompt configuration. Conversations are stored, analysed, and can feed back into the agent via learning entries.
Scenario: A SaaS company deploys a support chatbot on their docs site and a Telegram bot for their community. Both are powered by the same "Support Agent" in FleetQ. Corrections made via learning entries automatically improve future responses.
Overview
Web Widget
Embed a chat widget on any website with a one-line JavaScript snippet. Each visitor gets an isolated session.
Telegram Bot
Connect a Telegram bot to route messages to the FleetQ assistant, a specific agent, or a workflow.
Learning
Corrections and feedback are stored as learning entries and used to improve future agent responses.
Creating a chatbot
Navigate to Chatbots in the sidebar and click New Chatbot, or use the API. The following fields are available:
| Field | Description |
|---|---|
| name | Display name for the chatbot (shown in the widget header). |
| description | Internal description for team reference. |
| agent_id | The FleetQ agent that powers this chatbot. The agent's model, tools, and skills are all applied. |
| greeting_message | Opening message shown to users when they start a conversation. |
| appearance | JSONB object controlling widget colours, position, and avatar. |
curl -X POST /api/v1/chatbots \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Support Bot",
"description": "Customer-facing support chatbot",
"agent_id": "AGENT_ID",
"greeting_message": "Hi! How can I help you today?",
"appearance": {
"primary_color": "#6366f1",
"position": "bottom-right"
}
}'
Chatbot features
Web widget embed
Once a chatbot is created, copy the JavaScript snippet from its detail page and paste it before
the closing </body> tag on any page.
<script
src="https://your-fleetq-domain.com/widget.js"
data-chatbot-id="CHATBOT_ID"
data-token="CHATBOT_API_TOKEN"
async
></script>
Session management
Every browser visitor receives a separate, isolated conversation. Sessions are identified by a
unique session token stored in localStorage.
Conversations persist across page reloads for the same visitor. Anonymous visitors are tracked
by session; authenticated visitors can be identified by passing a user_id
attribute to the widget script.
Learning entries
Operators can mark a chatbot response as incorrect and provide the expected answer. This creates a learning entry associated with the chatbot. The backing agent incorporates learning entries into its context on subsequent requests, improving accuracy over time without requiring a full fine-tune.
Knowledge base indexing
A chatbot can index external knowledge sources so its backing agent can answer with up-to-date, grounded information. Indexing runs on a schedule and stores chunks in the team's knowledge base with the chatbot's tag so retrieval stays scoped to this bot.
| Source | What gets indexed |
|---|---|
| GitHub repo | Markdown files, README, and docs directories. Supports private repos via the GitHub integration. |
| Notion workspace | Pages and databases. Each page is chunked and embedded; hierarchical context is preserved. |
| Confluence space | All pages in a space via the Atlassian REST API. |
| Uploaded documents | PDF / TXT / MD / CSV dropped into the chatbot detail page. |
Human escalation
When the backing agent signals uncertainty (low confidence, explicit "I don't know", or a user clicking "Talk to a human"), the conversation is flagged for escalation. FleetQ creates a Human Task in the Approval Inbox with the full chat history so an operator can jump in, reply, and mark the session as resolved. The chatbot resumes AI control on the next inbound message unless the operator keeps the session locked.
Widget streaming & isolation
The widget is rendered inside a Shadow DOM so host-page CSS can never break it (and your widget styles can't bleed out into the host). Messages stream via Server-Sent Events (SSE) so users see the agent's reply token-by-token, exactly like a native chat product.
Analytics
The chatbot analytics summary tracks:
- Total conversations and messages
- Average response quality score
- User satisfaction ratings (thumbs up / thumbs down)
- Most common topics and unanswered questions
Chatbot API tokens
Each chatbot uses a dedicated API token scoped to that chatbot only. This token is embedded in the widget snippet and authenticates widget requests. Generate a token via the UI or the API:
POST /api/v1/chatbots/{id}/tokens
Telegram bots
Connect FleetQ to Telegram by registering a Telegram bot. Incoming Telegram messages are routed through FleetQ and processed by a configurable routing mode.
Routing modes
| Mode | Behaviour |
|---|---|
| assistant | Messages are routed to the FleetQ AI assistant, which has access to all platform tools and conversations. |
| agent | Messages are sent directly to a specific FleetQ agent for execution. Best for task-focused bots. |
| workflow | Incoming messages trigger a FleetQ workflow. The message text is passed as the workflow input. |
Chat bindings
A chat binding maps a specific Telegram chat (group, channel, or DM) to a FleetQ conversation context. Bindings allow you to route messages from different Telegram chats to different agents or workflows, keeping conversations isolated.
Webhook-based delivery
FleetQ receives Telegram updates via the Telegram Bot API webhook at
/api/telegram/webhook/{teamId}.
The webhook is authenticated with a secret token set during bot registration.
Incoming updates are queued and processed asynchronously via
ProcessTelegramMessageJob.
Telegram setup
Create a bot via @BotFather
@BotFather.
Send /newbot, choose a name and username,
then copy the bot token provided.
Register the bot in FleetQ
# Via MCP tool
telegram_bot_manage(action="register", bot_token="YOUR_BOT_TOKEN", routing_mode="assistant")
Webhook auto-registration
setWebhook call is needed.
The secret token used to authenticate incoming requests is generated and stored automatically.
Configure routing
ngrok or expose.
MCP tools
All chatbot and Telegram operations are available as MCP tools for LLM agents and the FleetQ assistant.
| Tool | Description |
|---|---|
| chatbot_list | List all chatbots with status and agent assignment. |
| chatbot_get | Retrieve full details of a single chatbot including appearance settings. |
| chatbot_create | Create a new chatbot backed by a specific agent. |
| chatbot_update | Update chatbot name, description, greeting, appearance, or backing agent. |
| chatbot_toggle_status | Enable or disable a chatbot. Disabled chatbots stop accepting new conversations. |
| chatbot_session_list | List active and historical sessions for a chatbot. |
| chatbot_analytics_summary | Return conversation counts, response quality scores, and satisfaction ratings. |
| chatbot_learning_entries | List or add learning entries (corrections and preferred responses) for a chatbot. |
| telegram_bot_manage | Register, update, or remove a Telegram bot. Supports actions: register, update, delete. |
API endpoints
Full OpenAPI 3.1 documentation is available at /docs/api. All endpoints require a Sanctum bearer token.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/chatbots | List all chatbots (cursor-paginated). |
| GET | /api/v1/chatbots/{id} | Retrieve a single chatbot. |
| POST | /api/v1/chatbots | Create a chatbot. |
| PUT | /api/v1/chatbots/{id} | Update a chatbot. |
| DELETE | /api/v1/chatbots/{id} | Delete a chatbot and all associated sessions. |
| POST | /api/v1/chatbots/{id}/tokens | Generate a new API token for the widget embed. |
| GET | /api/v1/chatbots/{id}/conversations | List all conversations for a chatbot (cursor-paginated). |