bloby-bot 0.60.1 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: telegram
3
+ description: "Telegram channel for your agent. Two-tap pairing creates a private bot, then your Bloby talks to Telegram directly. Messaging, voice notes, photos, channel/business/assistant modes."
4
+ ---
5
+
6
+ # Telegram
7
+
8
+ ## What This Is
9
+
10
+ Gives your agent its own Telegram bot. Connect in two taps (no token, no copy-paste), then send and receive messages, handle voice notes and photos, and switch between personal (channel), business, and assistant modes.
11
+
12
+ Under the hood: Bloby's relay provisions a private bot for you via Telegram's "Managed Bots" feature, hands the token to your Bloby, and steps out. From then on **your Bloby talks to Telegram directly** — the relay is never in the message path. It keeps working behind any network with no public URL.
13
+
14
+ ## Dependencies
15
+
16
+ None.
17
+
18
+ ---
19
+
20
+ ## How Responses Work
21
+
22
+ **Your text response IS the Telegram reply.** When you receive a message tagged with `[Telegram | ...]`, the supervisor takes whatever you respond with and sends it directly to that Telegram chat. You do NOT need to use curl or `/api/channels/send` to reply — just respond normally.
23
+
24
+ **Do NOT use `/api/channels/send` to reply to incoming Telegram messages.** That endpoint is ONLY for proactive messages (during pulse, cron, or when you want to start a conversation). If you use it to reply, the person will get duplicate messages.
25
+
26
+ **Adjust your style for Telegram:** Keep it conversational and concise. Telegram supports basic formatting but no markdown headers — think chat, not a document.
27
+
28
+ ### Routing is supervisor-enforced
29
+
30
+ Each incoming message is tagged with its routing target the moment it enters your conversation. The supervisor pins your reply to whatever surface triggered it — chat-bubble messages land in chat, Telegram messages reply to the originating Telegram chat. You don't need to track which channel you're on — **the tag (`[Telegram | chatId | role | name]`) is the truth, and the supervisor handles delivery.**
31
+
32
+ ---
33
+
34
+ ## How Messages Arrive
35
+
36
+ When a message arrives via Telegram, the supervisor wraps it with context:
37
+
38
+ ```
39
+ [Telegram | 123456789 | customer | Alice]
40
+ Hi, I'd like to schedule an appointment.
41
+ ```
42
+
43
+ The format is: `[Telegram | chatId | role | name (optional)]`
44
+
45
+ - **chatId** — the Telegram chat id. For a 1:1 chat this is the person's numeric user id. Use it as the `to` value when sending proactive messages to that person.
46
+ - **role=admin**: Your human (the bot owner) or a configured admin. Use your normal personality and full capabilities.
47
+ - **role=customer**: Someone else messaging your bot. Follow the active skill's SCRIPT.md.
48
+ - **role=assistant**: Your human triggered you with `@botname:` inside a chat. You have the conversation context — execute and respond concisely.
49
+
50
+ ---
51
+
52
+ ## Channel Config
53
+
54
+ Your channel configuration lives in `~/.bloby/config.json` under `channels.telegram` — a file the supervisor manages, outside your workspace. It holds the bot token (provisioned at pairing), the bot @username, the owner's Telegram user id, and the mode.
55
+
56
+ ---
57
+
58
+ ## Modes
59
+
60
+ The mode sets the routing/security policy for inbound messages. The core (supervisor) enforces it; your skill decides which mode is active. Switch via `/api/channels/telegram/configure`.
61
+
62
+ **Channel Mode** (default): "Just talk to me." Only the bot owner's direct messages trigger the agent. Messages from anyone else are ignored. Groups are ignored in channel mode.
63
+
64
+ **Business Mode**: Your bot is customer-facing. Telegram user ids in the `admins` array get admin access (your main system prompt). Everyone else is a customer and gets the support prompt from the active skill's SCRIPT.md.
65
+
66
+ **Assistant Mode**: Personal assistant in your conversations. The owner's DMs work as a normal admin channel. Other people's messages are stored silently for context. When the owner types `@botname: <command>` in a chat (or a group, if `allowGroups` is on), the agent activates with the conversation context and responds in that chat.
67
+
68
+ > Telegram has no "message yourself" like WhatsApp — your bot is its own contact. "Channel mode" means **only you (the owner) can talk to it**; everyone else is ignored.
69
+
70
+ ### Group chats (`allowGroups`)
71
+
72
+ Off by default. Enable per-channel with `allowGroups`. In business mode group members are routed by `admins` (admin vs customer); in assistant mode the owner can `@botname:` inside a group to act with the group's context. The reply goes to the group.
73
+
74
+ ```bash
75
+ curl -s -X POST http://localhost:7400/api/channels/telegram/configure \
76
+ -H "Content-Type: application/json" -d '{"allowGroups":true}'
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Setup
82
+
83
+ ### 1. Connect Telegram
84
+
85
+ When your human asks to connect Telegram, give them the pairing page (send it as a relative URL — their browser is already on the right domain). The dashboard renders any `/pair-page` URL as a button:
86
+
87
+ ```
88
+ /api/channels/telegram/pair-page
89
+ ```
90
+
91
+ That page does everything: it asks the relay to provision a private bot, shows a **"Create my bot"** button that opens Telegram, and links automatically once the human taps **Create Bot** inside Telegram. No token, no copy-paste.
92
+
93
+ The default mode after pairing is **channel** (owner-only).
94
+
95
+ You do not need to call `connect` yourself — the pair-page handles provisioning. (`POST /api/channels/telegram/connect` exists if you want to fetch the deep link directly.)
96
+
97
+ ### 2. Choose a Mode
98
+
99
+ **Channel mode** (default) — personal assistant, owner-only:
100
+
101
+ ```bash
102
+ curl -s -X POST http://localhost:7400/api/channels/telegram/configure \
103
+ -H "Content-Type: application/json" -d '{"mode":"channel"}'
104
+ ```
105
+
106
+ **Business mode** — customer-facing. Admins get full access; everyone else gets the skill's SCRIPT.md:
107
+
108
+ ```bash
109
+ curl -s -X POST http://localhost:7400/api/channels/telegram/configure \
110
+ -H "Content-Type: application/json" \
111
+ -d '{"mode":"business","admins":["YOUR_TELEGRAM_USER_ID"],"skill":"SKILL_FOLDER_NAME"}'
112
+ ```
113
+
114
+ Replace `YOUR_TELEGRAM_USER_ID` with the admin's **numeric Telegram user id** (NOT a phone number or @username). In a 1:1 chat this id is exactly the `chatId` shown in the message tag — so the easiest way to find it is to have the person message the bot once and read the tag.
115
+
116
+ **Assistant mode** — personal assistant inside your conversations:
117
+
118
+ ```bash
119
+ curl -s -X POST http://localhost:7400/api/channels/telegram/configure \
120
+ -H "Content-Type: application/json" -d '{"mode":"assistant","skill":"SKILL_FOLDER_NAME"}'
121
+ ```
122
+
123
+ The trigger uses the bot's name from `config.json` `username` (e.g. `@bloby:`). By default **only the owner** can trigger — other people's messages are context only.
124
+
125
+ ### ⚠️ Shared control — `allowOthersToTrigger` (DANGEROUS)
126
+
127
+ By default only the owner can drive the agent with `@botname:`. Setting `allowOthersToTrigger: true` lets **anyone** who tags the bot drive an agent that can run Bash, edit files, send messages, and spend money. **Warn your human, in your own words, before enabling it.** It's for genuinely trusted shared use only, and can be turned off at any time. Default is `false` — leave it off unless your human clearly understands the risk and asks for it.
128
+
129
+ ### 3. Verify
130
+
131
+ ```bash
132
+ curl -s http://localhost:7400/api/channels/status
133
+ ```
134
+
135
+ Expected: `"channel":"telegram","connected":true`
136
+
137
+ ---
138
+
139
+ ## Sending Proactive Messages
140
+
141
+ To INITIATE a message (pulse, cron, or reaching out first):
142
+
143
+ ```bash
144
+ curl -s -X POST http://localhost:7400/api/channels/send \
145
+ -H "Content-Type: application/json" \
146
+ -d '{"channel":"telegram","to":"123456789","text":"Your appointment is confirmed for tomorrow at 2pm."}'
147
+ ```
148
+
149
+ `to` is the Telegram **chatId** — take it from a prior message's `[Telegram | chatId | ...]` tag.
150
+
151
+ **Telegram rule:** a bot can never message someone *first*. The person must have started a chat with your bot at least once (which they did if you've ever received a message from them). You cannot cold-message an arbitrary user id, phone number, or @username. If a person has blocked the bot, sends to them silently fail.
152
+
153
+ **Remember:** proactive only. When replying to an incoming message, just respond normally.
154
+
155
+ ### Send an image
156
+
157
+ Embed `<BlobyImage src="/api/files/chart.png" alt="..." />` in your reply, or for proactive sends use `/api/channels/send` with a `media` object (`{"type":"image","path":"..."}`).
158
+
159
+ ---
160
+
161
+ ## Voice Notes & Photos
162
+
163
+ - **Voice notes** are downloaded and transcribed automatically (needs an OpenAI/Whisper key in your Bloby settings) and delivered as text.
164
+ - **Photos** arrive as image attachments you can see and reason about.
165
+ - Other attachment types (documents, videos, stickers, locations) aren't read in this version — if someone sends one with no caption, ask them to describe it or send a photo/text instead.
166
+
167
+ ## Typing Indicator
168
+
169
+ The agent shows "typing…" while composing — handled by the supervisor, no action needed.
170
+
171
+ ---
172
+
173
+ ## Customer Conversation Logs
174
+
175
+ When you finish a conversation with a **customer**, save a summary to `telegram/{chatId}.md`: key details, outcome, follow-ups, timestamp. Next time they message, read their file first.
176
+
177
+ ---
178
+
179
+ ## Account Management
180
+
181
+ **Disconnect** (stop polling, keep the bot for later):
182
+ ```bash
183
+ curl -s -X POST http://localhost:7400/api/channels/telegram/disconnect
184
+ ```
185
+
186
+ **Reconnect** (resume the same bot after a disconnect, no re-pairing):
187
+ ```bash
188
+ curl -s -X POST http://localhost:7400/api/channels/telegram/reconnect
189
+ ```
190
+
191
+ **Logout** (stop + forget the token; re-pair to reconnect):
192
+ ```bash
193
+ curl -s -X POST http://localhost:7400/api/channels/telegram/logout
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Human Interaction
199
+
200
+ - Pairing is two taps: **Create my bot** → **Create Bot** in Telegram. No token or copy-paste.
201
+ - Your human's bot is a normal Telegram contact — they (and anyone they share it with) message it directly.
202
+ - In business mode, explain that admin user ids get full agent access while everyone else gets the customer-facing skill.
203
+ - Privacy: the bot token is stored locally at `~/.bloby/config.json`. Messages flow directly between this machine and Telegram — they do not pass through Bloby's servers.
204
+
205
+ ---
206
+
207
+ ## API Reference
208
+
209
+ | Endpoint | Method | Purpose |
210
+ |----------|--------|---------|
211
+ | `/api/channels/status` | GET | List all channel statuses |
212
+ | `/api/channels/telegram/status` | GET | Telegram channel status |
213
+ | `/api/channels/telegram/pair-page` | GET | Pairing page (hand this to the human) |
214
+ | `/api/channels/telegram/connect` | POST | Start provisioning, returns the t.me deep link |
215
+ | `/api/channels/telegram/poll?sessionId=…` | GET | Poll provisioning; links when the bot is created |
216
+ | `/api/channels/telegram/configure` | POST | Set mode + admins + skill |
217
+ | `/api/channels/telegram/disconnect` | POST | Stop polling (keep token) |
218
+ | `/api/channels/telegram/reconnect` | POST | Resume the same bot after a disconnect |
219
+ | `/api/channels/telegram/logout` | POST | Stop + delete token |
220
+ | `/api/channels/send` | POST | Send a proactive message/media |
221
+
222
+ All endpoints use `http://localhost:7400` for internal calls. For URLs shown to your human, use relative paths (e.g. `/api/channels/telegram/pair-page`).
223
+
224
+ ---
225
+
226
+ ## Technical Notes
227
+
228
+ - Your Bloby long-polls Telegram directly (`getUpdates`). It reconnects automatically on network drops.
229
+ - If you ever get a `409 Conflict`, another process is consuming the same bot token — only one consumer is allowed per bot. Disconnect the other one.
230
+ - Telegram message limit is 4096 characters; longer replies are split automatically.
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "telegram",
3
+ "version": "1.0.0",
4
+ "type": "skill",
5
+ "bloby_human": "Bruno Bertapeli",
6
+ "bloby": "bloby-bruno",
7
+ "author": "newbot-official",
8
+ "description": "Telegram channel for your agent. Two-tap pairing provisions a private bot (no token copy-paste), then your Bloby talks to Telegram directly. Messaging, voice notes, photos, channel/business/assistant modes.",
9
+ "depends": [],
10
+ "env_keys": [],
11
+ "has_telemetry": false,
12
+ "size": "10KB",
13
+ "contains_binaries": false,
14
+ "tags": ["telegram", "channel", "messaging"]
15
+ }