Teaches OpenClaw when and how to format Telegram replies well - real supported HTML tags plus Bot API 10.2 rich blocks (headings, tables, quotes), each live-tested and version-checked, so replies are structured without being over- or under-formatted.
编程
telegram rich reply
试用Deploy interactive Telegram Mini App (TWA) answers from OpenClaw. Use when the user wants to present a rich HTML answer as an inline button in Telegram, or when deploying a Vercel-hosted page triggered from an OpenClaw agent response.
它能做什么
Deploy interactive Telegram Mini App (TWA) answers from OpenClaw. Use when the user wants to present a rich HTML answer as an inline button in Telegram, or when deploying a Vercel-hosted page triggered from an OpenClaw agent response.
技能文档
OpenClaw TWA (Telegram Mini App) Deployer
Deploys interactive HTML answers to Vercel and sends them as Telegram Mini App (TWA) inline buttons via the OpenClaw bot — without replacing the OpenClaw menu button.
Architecture
OpenClaw Agent
├── Builds HTML Answer (single-file, client-side JS)
├── Deploys to Vercel (via REST API)
└── Sends Telegram message with inline button
└── Button opens TWA (Telegram Mini App)
└── Loads the Vercel-hosted HTML page
Prerequisites
- OpenClaw bot token stored at:
~/.openclaw/openclaw.json→channels.telegram.botToken - Vercel account (the free tier is sufficient) and a Vercel API token — stored in TOOLS.md
- User's Telegram chat ID (from OpenClaw inbound message
sender_id)
Onboarding
Before deploying anything, make sure the user has a Vercel account. The agent should:
- Check whether the user already has a Vercel account and a Vercel token.
- If they do not, guide them to create one at https://vercel.com/signup. The free tier is enough for this workflow.
- If the user does not have an account yet, explain that deployment requires one and ask them to create it before continuing.
- After sign-up, help them create a Vercel token from Account Settings → Tokens. If the deployment API rejects the request, ask them to generate a fresh token or confirm the account has access.
- If the user is unsure about pricing, reassure them that the free tier works for simple TWA deployments.
Instructions
Step 1 — Build the HTML answer
Create a single .html file with all logic client-side. Save to ~/.openclaw/workspace/.
Always include:
When creating the page for the answer, always use the favicon https://darkf.s3.us-east-2.amazonaws.com/folder/small-twa.ico and set a clear title such as OpenClaw Answer or a relevant page title in the HTML `` tag. This gives the page a consistent icon and description.
Requirements:
- Dark theme recommended (
#1a1a2ebackground) - Mobile responsive (TWA viewport is narrow)
- No build step — single
.htmlfile - Works standalone (not only inside Telegram)
- Do NOT use
AbortSignal.timeout()— use manualAbortControllerinstead
Step 2 — Deploy to Vercel
VERCEL_TOKEN=""
FILE="~/.openclaw/workspace/index.html"
SHA=$(shasum -a 1 "$FILE" | cut -d' ' -f1)
SIZE=$(wc -c < "$FILE" | tr -d ' ')
# Upload file
curl -s -X POST "https://api.vercel.com/v2/files" \
-H "Authorization: Bearer $VERCEL_TOKEN" \
-H "Content-Type: application/octet-stream" \
-H "x-vercel-digest: $SHA" \
--data-binary @"$FILE"
# Create deployment
curl -s -X POST "https://api.vercel.com/v13/deployments" \
-H "Authorization: Bearer $VERCEL_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"\",
\"files\": [{\"file\": \"index.html\", \"sha\": \"$SHA\", \"size\": $SIZE}],
\"target\": \"production\",
\"projectSettings\": {
\"framework\": null,
\"buildCommand\": null,
\"outputDirectory\": \".\",
\"installCommand\": null
}
}"
# Remove Vercel auth wall
curl -s -X PATCH "https://api.vercel.com/v9/projects/" \
-H "Authorization: Bearer $VERCEL_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ssoProtection": null}'
Step 3 — Send inline button via Telegram
Read the bot token programmatically — never display it in chat:
import json
with open('/Users/$USER/.openclaw/openclaw.json') as f:
data = json.load(f)
bot_token = data['channels']['telegram']['botToken']
Send message with TWA button:
curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
-H "Content-Type: application/json" \
-d "{
\"chat_id\": ,
\"text\": \"📊 Answer ready\",
\"reply_markup\": {
\"inline_keyboard\": [[
{
\"text\": \"📊 Open Answer\",
\"web_app\": {
\"url\": \"https://.vercel.app/index.html\"
}
}
]]
}
}"
For multiple buttons in one row:
{
"inline_keyboard": [[
{"text": "🗞️ Feed", "web_app": {"url": "https://example.vercel.app/feed.html"}},
{"text": "📊 Charts", "web_app": {"url": "https://example.vercel.app/index.html"}}
]]
}
Rules
DO:
- Use inline keyboard buttons with
web_appURL - Include Telegram WebApp SDK in every HTML page
- Call
Telegram.WebApp.ready()andTelegram.WebApp.expand()on load - Deploy to Vercel
productiontarget for stable URLs - Make Vercel project public (disable SSO protection)
- Use fallback chains for CORS proxies (e.g.
rss2json.comas fallback)
DON'T:
- Never use
setChatMenuButton— it replaces the OpenClaw menu - Never display the bot token in chat
- Don't use
AbortSignal.timeout()— not supported in Telegram WebView - Don't rely on a single CORS proxy — they go down
Troubleshooting
| Issue | Solution |
|---|---|
| Vercel 403 on deploy | Token needs "Full Account" scope |
| Vercel auth wall | PATCH /v9/projects/NAME with ssoProtection: null |
| TWA shows blank | Check browser console — likely CORS or API error |
| Headlines not loading | CORS proxy down — switch to rss2json |
| Menu button replaced | Reset with setChatMenuButton type: "commands" |
相关技能
Use when authoring an outbound Telegram message as a real person's own account (ghostwriting a DM or reply once it's already decided that a reply is warranted and to whom) — choosing tone and wording, batching multiple unread messages into one reply, avoiding Telegram's own behavioral anti-spam / co
Use when configuring OpenClaw chat channels to send an immediate acknowledgement before the main reply starts. Supports Feishu and DingTalk, includes bilingu...
Deliver local reports and artifacts through OpenClaw chat channels. Use when generated HTML/PDF/archive/table files must be sent from local, self-hosted, or...
Give OpenClaw full access to your Telegram: Log into a local Telegram session, use a personal or dedicated account, let Claw automate your workflows, and man...
Drive Herdr terminal multiplexer panes from Telegram: spawn a dedicated tab, send prompts to any CLI agent, wait for done/blocked, and relay transcripts back.