Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

17.4 KB
Raw Blame
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["5351"],{86019(e,s,n){n.r(s),n.d(s,{metadata:()=>r,default:()=>h,frontMatter:()=>d,contentTitle:()=>l,toc:()=>a,assets:()=>c});var r=JSON.parse('{"id":"integrations/telegram","title":"Telegram","description":"Mercury connects to Telegram via a bot token, providing a mobile-first interface with streaming, file uploads, inline approval keyboards, and real-time task progress.","source":"@site/docs/integrations/telegram.mdx","sourceDirName":"integrations","slug":"/integrations/telegram","permalink":"/docs/integrations/telegram","draft":false,"unlisted":false,"editUrl":"https://github.com/cosmicstack-labs/mercury-agent/tree/main/website/docs/integrations/telegram.mdx","tags":[],"version":"current","frontMatter":{"id":"telegram","title":"Telegram"},"sidebar":"docsSidebar","previous":{"title":"GitHub Companion","permalink":"/docs/integrations/github-companion"},"next":{"title":"Discord","permalink":"/docs/integrations/discord"}}'),t=n(74848),i=n(28453);let d={id:"telegram",title:"Telegram"},l,c={},a=[{value:"Access Model",id:"access-model",level:2},{value:"Roles",id:"roles",level:3},{value:"CLI Commands",id:"cli-commands",level:3},{value:"Bot Commands Menu",id:"bot-commands-menu",level:2},{value:"Real-Time Task Progress",id:"real-time-task-progress",level:2},{value:"How It Works",id:"how-it-works",level:3},{value:"What the Status Card Looks Like",id:"what-the-status-card-looks-like",level:3},{value:"Single-Message Design",id:"single-message-design",level:3},{value:"Completion",id:"completion",level:3},{value:"Permission Mode",id:"permission-mode",level:2},{value:"Ephemeral Messages",id:"ephemeral-messages",level:3},{value:"Features",id:"features",level:2},{value:"Configuration",id:"configuration",level:2}];function o(e){let s={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.p,{children:"Mercury connects to Telegram via a bot token, providing a mobile-first interface with streaming, file uploads, inline approval keyboards, and real-time task progress."}),"\n",(0,t.jsx)(s.h2,{id:"access-model",children:"Access Model"}),"\n",(0,t.jsxs)(s.p,{children:["Mercury uses an ",(0,t.jsx)(s.strong,{children:"organization access model"})," with admins and members. The first user becomes the admin by completing a pairing-code flow during setup. Additional users request access by sending ",(0,t.jsx)(s.code,{children:"/start"}),", which admins can approve or reject."]}),"\n",(0,t.jsx)(s.admonition,{title:"First-time pairing",type:"info",children:(0,t.jsxs)(s.p,{children:["When no admins exist yet, sending ",(0,t.jsx)(s.code,{children:"/start"})," creates a ",(0,t.jsx)(s.strong,{children:"pairing code"})," that must be entered in the CLI to complete setup. This ensures only the legitimate owner can gain initial access. Once an admin exists, new users send ",(0,t.jsx)(s.code,{children:"/start"})," to create a pending request that admins can approve or reject."]})}),"\n",(0,t.jsx)(s.admonition,{title:"Private chats only",type:"warning",children:(0,t.jsx)(s.p,{children:"Mercury only works in private (one-to-one) chats. Messages in groups or channels are always ignored."})}),"\n",(0,t.jsx)(s.h3,{id:"roles",children:"Roles"}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Role"}),(0,t.jsx)(s.th,{children:"Description"}),(0,t.jsx)(s.th,{children:"Can approve requests?"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.strong,{children:"Admin"})}),(0,t.jsx)(s.td,{children:"First user to pair. Can approve/reject access requests, promote/demote users, and reset all access."}),(0,t.jsx)(s.td,{children:"Yes"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.strong,{children:"Member"})}),(0,t.jsx)(s.td,{children:"Approved by an admin. Can send messages and receive responses."}),(0,t.jsx)(s.td,{children:"No"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.strong,{children:"Pending"})}),(0,t.jsxs)(s.td,{children:["Sent ",(0,t.jsx)(s.code,{children:"/start"})," but not yet approved. Can only see their pending status."]}),(0,t.jsx)(s.td,{children:"No"})]})]})]}),"\n",(0,t.jsx)(s.h3,{id:"cli-commands",children:"CLI Commands"}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Command"}),(0,t.jsx)(s.th,{children:"Description"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram list"})}),(0,t.jsx)(s.td,{children:"Show approved admins, members, and pending requests"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram approve <code|userId>"})}),(0,t.jsx)(s.td,{children:"Approve the first pairing code or a pending request by user ID"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram reject <userId>"})}),(0,t.jsx)(s.td,{children:"Reject a pending access request"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram remove <userId>"})}),(0,t.jsx)(s.td,{children:"Remove an approved admin or member"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram promote <userId>"})}),(0,t.jsx)(s.td,{children:"Promote a member to admin"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram demote <userId>"})}),(0,t.jsx)(s.td,{children:"Demote an admin to member (at least one admin must remain)"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"mercury telegram reset"})}),(0,t.jsx)(s.td,{children:"Clear all Telegram access (admins, members, pending). Start fresh."})]})]})]}),"\n",(0,t.jsx)(s.h2,{id:"bot-commands-menu",children:"Bot Commands Menu"}),"\n",(0,t.jsx)(s.p,{children:"Mercury registers 15 commands in Telegram's bot menu for quick access:"}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Command"}),(0,t.jsx)(s.th,{children:"Description"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/start"})}),(0,t.jsx)(s.td,{children:"Request access to this Mercury instance"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/help"})}),(0,t.jsx)(s.td,{children:"Show Telegram-specific command reference"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/status"})}),(0,t.jsx)(s.td,{children:"Config, budget, and uptime"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/progress"})}),(0,t.jsx)(s.td,{children:"Live status for the current task"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/stop"})}),(0,t.jsx)(s.td,{children:"Stop this chat's task, the agents it started and its waiting messages (other chats keep going)"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/budget"})}),(0,t.jsx)(s.td,{children:"Token budget status and management"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/stream"})}),(0,t.jsx)(s.td,{children:"Toggle text streaming on/off"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/memory"})}),(0,t.jsx)(s.td,{children:"Second brain memory"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/permissions"})}),(0,t.jsx)(s.td,{children:"Switch Ask Me / Allow All mode"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/models"})}),(0,t.jsx)(s.td,{children:"List providers or switch AI model"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/code"})}),(0,t.jsx)(s.td,{children:"Programming mode (plan / execute / off)"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/agents"})}),(0,t.jsx)(s.td,{children:"List and manage sub-agents"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/bg"})}),(0,t.jsx)(s.td,{children:"Background tasks"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/spotify"})}),(0,t.jsx)(s.td,{children:"Spotify playback controls"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"/unpair"})}),(0,t.jsx)(s.td,{children:"Reset all Telegram access (admin only)"})]})]})]}),"\n",(0,t.jsx)(s.admonition,{title:"Telegram-specific help",type:"tip",children:(0,t.jsxs)(s.p,{children:["Running ",(0,t.jsx)(s.code,{children:"/help"})," on Telegram shows a clean, Telegram-formatted command reference with only Telegram-relevant commands \u2014 no CLI-only features like workspace IDE or progress views."]})}),"\n",(0,t.jsx)(s.h2,{id:"real-time-task-progress",children:"Real-Time Task Progress"}),"\n",(0,t.jsxs)(s.p,{children:["During multi-step tasks, Mercury uses a ",(0,t.jsx)(s.strong,{children:"single status card"})," that updates in place. This keeps the chat clean \u2014 you see one message that shows what's happening, not a flood of separate updates."]}),"\n",(0,t.jsx)(s.h3,{id:"how-it-works",children:"How It Works"}),"\n",(0,t.jsxs)(s.ol,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Step 1 begins"})," \u2014 Mercury creates a status card: ",(0,t.jsx)(s.code,{children:"\u2699\uFE0F Mercury working (step 1)"})]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Steps progress"})," \u2014 The same message is edited to show the latest steps with checkmarks"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Step 3+ (substantial task)"})," \u2014 The status card is ",(0,t.jsx)(s.strong,{children:"pinned"})," to the top of the chat so you can always see progress without scrolling"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Notices"})," \u2014 System messages like Mercury Autopilot warnings are folded into the status card instead of creating separate messages"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Task completes"})," \u2014 The status card is unpinned and deleted. The AI response and completion banner appear as fresh messages"]}),"\n"]}),"\n",(0,t.jsx)(s.h3,{id:"what-the-status-card-looks-like",children:"What the Status Card Looks Like"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{children:"\u2699\uFE0F Mercury working (step 5)\n\n\u2705 read_file \xb7 src/index.ts\n\u2705 edit_file \xb7 src/utils.ts\n\u2705 run_command \xb7 npm test\n\u2705 read_file \xb7 package.json\n\u23F3 write_file \xb7 src/config.ts\u2026\n"})}),"\n",(0,t.jsx)(s.h3,{id:"single-message-design",children:"Single-Message Design"}),"\n",(0,t.jsxs)(s.p,{children:["During an active task, ",(0,t.jsx)(s.strong,{children:"no new messages are created"})," in the chat. Everything is consolidated into the pinned status card:"]}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Tool progress"})," \u2014 edited in place with a rolling window of the last 5 completed steps"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Autopilot warnings"})," \u2014 shown as notice lines in the status card (last 3 notices)"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"AI responses"})," \u2014 deferred until the task completes, then sent as a clean message"]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"Permission prompts"})," \u2014 shown as ephemeral inline keyboard messages, deleted after you respond"]}),"\n"]}),"\n",(0,t.jsx)(s.p,{children:"This means you never have to scroll up to find the progress indicator \u2014 it stays pinned at the top until the task is done."}),"\n",(0,t.jsx)(s.h3,{id:"completion",children:"Completion"}),"\n",(0,t.jsx)(s.p,{children:"When a substantial task finishes (3+ steps and 30+ seconds), Mercury sends a completion banner:"}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{children:"\u2705 Task complete (8 steps \xb7 45s)\n\u263F claude-sonnet via anthropic \xb7 12.4k tokens\nBudget: \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591 67% (67.2k / 100.0k)\n\n  \u2713 read_file \xb7 src/index.ts\n  \u2713 edit_file \xb7 src/utils.ts\n  \u2713 run_command \xb7 npm test\n"})}),"\n",(0,t.jsx)(s.h2,{id:"permission-mode",children:"Permission Mode"}),"\n",(0,t.jsx)(s.p,{children:"At the start of each Telegram session, Mercury shows an inline keyboard to choose a permission mode:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"\u{1F512} Ask Me"})," \u2014 Mercury asks before file writes, shell commands, and scope changes. Prompts appear as inline keyboards with Allow / Always / Deny buttons."]}),"\n",(0,t.jsxs)(s.li,{children:[(0,t.jsx)(s.strong,{children:"\u2705 Allow All"})," \u2014 Auto-approve everything for this session. No interruptions."]}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["Use ",(0,t.jsx)(s.code,{children:"/permissions"}),' at any time to switch modes. Choosing "Always" on any permission prompt flips to auto-approve for the rest of the session.']}),"\n",(0,t.jsx)(s.h3,{id:"ephemeral-messages",children:"Ephemeral Messages"}),"\n",(0,t.jsxs)(s.p,{children:["Permission prompts, loop-continuation prompts, and mode-selection cards are ",(0,t.jsx)(s.strong,{children:"ephemeral"})," \u2014 they're deleted automatically after you respond (or after a 2-minute timeout). This keeps the chat clean."]}),"\n",(0,t.jsx)(s.h2,{id:"features",children:"Features"}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Feature"}),(0,t.jsx)(s.th,{children:"Description"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Single status card"}),(0,t.jsx)(s.td,{children:"One message edited in place during multi-step tasks \u2014 no message clutter"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Pinned progress"}),(0,t.jsx)(s.td,{children:"Status card pinned to chat top for tasks with 3+ steps"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Text streaming"}),(0,t.jsxs)(s.td,{children:["Real-time response editing with typing indicators (toggle with ",(0,t.jsx)(s.code,{children:"/stream"}),")"]})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"File uploads"}),(0,t.jsx)(s.td,{children:"Photos, audio, video, and documents auto-detected and sent with the right API"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"HTML formatting"}),(0,t.jsx)(s.td,{children:"Markdown automatically converted to Telegram-compatible HTML"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Inline keyboards"}),(0,t.jsx)(s.td,{children:"Permission and mode prompts shown as tappable buttons"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Ephemeral prompts"}),(0,t.jsx)(s.td,{children:"Permission and mode cards auto-deleted after response"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Completion banners"}),(0,t.jsx)(s.td,{children:"Token usage and budget stats for substantial tasks"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Multi-user access"}),(0,t.jsx)(s.td,{children:"Organization model with admins and members"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:"Bot commands menu"}),(0,t.jsx)(s.td,{children:"15 commands registered in Telegram's bot menu for quick access"})]})]})]}),"\n",(0,t.jsx)(s.h2,{id:"configuration",children:"Configuration"}),"\n",(0,t.jsxs)(s.p,{children:["Telegram is set up during ",(0,t.jsx)(s.code,{children:"mercury doctor"})," or initial onboarding. You need a bot token from ",(0,t.jsx)(s.a,{href:"https://t.me/BotFather",children:"@BotFather"}),"."]}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Variable"}),(0,t.jsx)(s.th,{children:"Description"}),(0,t.jsx)(s.th,{children:"Default"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"TELEGRAM_BOT_TOKEN"})}),(0,t.jsx)(s.td,{children:"Bot token from @BotFather"}),(0,t.jsx)(s.td,{children:"\u2014"})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"TELEGRAM_ENABLED"})}),(0,t.jsx)(s.td,{children:"Enable/disable Telegram channel"}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"false"})})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"TELEGRAM_STREAMING"})}),(0,t.jsx)(s.td,{children:"Enable real-time text streaming"}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"true"})})]})]})]}),"\n",(0,t.jsxs)(s.p,{children:["Type ",(0,t.jsx)(s.code,{children:"none"})," as the bot token during ",(0,t.jsx)(s.code,{children:"mercury doctor"})," to disable Telegram."]})]})}function h(e={}){let{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(o,{...e})}):o(e)}},28453(e,s,n){n.d(s,{R:()=>d,x:()=>l});var r=n(96540);let t={},i=r.createContext(t);function d(e){let s=r.useContext(i);return r.useMemo(function(){return"function"==typeof e?e(s):{...s,...e}},[s,e])}function l(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:d(e.components),r.createElement(i.Provider,{value:s},e.children)}}}]);