Telegram Business Bot
Build business automation on Telegram — lead capture forms, appointment booking, FAQ bots, payments, and community management.
Quick Start
CODEBLOCK0
Bot Setup
1. Create Bot via @BotFather
- 1. Open Telegram, search for INLINECODE0
- Send INLINECODE1
- Choose name and username (must end in
bot) - Copy the token → set as INLINECODE3
2. Configure Bot
CODEBLOCK1
3. Webhook Setup
CODEBLOCK2
Available Commands
Messaging
CODEBLOCK3
Inline Keyboards
CODEBLOCK4
Lead Capture
CODEBLOCK5
FAQ System
CODEBLOCK6
Media
CODEBLOCK7
Lead Capture Flow
The bot guides users through a multi-step form:
- 1. Start → Welcome message with menu buttons
- "Get Quote" → Asks for name
- User sends name → Asks for email
- User sends email → Asks for phone (optional)
- User sends phone → Asks for service interest (buttons)
- User selects service → Confirmation + thank you
- Lead data is output as JSON for CRM integration
Integration with CRM
CODEBLOCK8
FAQ Automation
Define your FAQ in the script's FAQ_DATABASE:
CODEBLOCK9
The FAQ matcher uses keyword matching + fuzzy similarity. For AI-powered matching, pipe through the LLM.
Payment Integration
Telegram supports native payments via Payment Providers (Stripe, etc.):
CODEBLOCK10
Note: amount is in smallest currency unit (cents for USD). $99.00 = 9900.
Group Management
CODEBLOCK11
Webhook Payload Handling
When using webhooks, incoming updates look like:
Message:
CODEBLOCK12
Callback (button press):
CODEBLOCK13
Parse with:
CODEBLOCK14
Credits
Built by
M. Abidi |
agxntsix.ai
YouTube |
GitHub
Part of the
AgxntSix Skill Suite for OpenClaw agents.
📅 Need help setting up OpenClaw for your business? Book a free consultation
Telegram 商业机器人
在 Telegram 上构建业务自动化——包括潜在客户获取表单、预约预订、常见问题解答机器人、支付和社区管理。
快速开始
bash
export TELEGRAMBOTTOKEN=123456:ABC-DEF...
发送消息
python3 {baseDir}/scripts/telegram
business.py send-message id> 来自您的商业机器人的问候!
发送内联键盘
python3 {baseDir}/scripts/telegrambusiness.py send-menu id> 我能如何帮助您? [{text:📅 预约,callbackdata:book},{text:❓ 常见问题,callbackdata:faq},{text:💬 联系销售,callback_data:sales}]
开始潜在客户获取
python3 {baseDir}/scripts/telegrambusiness.py send-lead-form id>
机器人设置
1. 通过 @BotFather 创建机器人
- 1. 打开 Telegram,搜索 @BotFather
- 发送 /newbot
- 选择名称和用户名(必须以 bot 结尾)
- 复制令牌 → 设置为 TELEGRAMBOTTOKEN
2. 配置机器人
/setdescription - 机器人资料上显示的业务描述
/setabouttext - 简短介绍文本
/setuserpic - 机器人头像
/setcommands - 设置命令菜单:
start - 开始使用
book - 预约
faq - 常见问题解答
contact - 联系我们
help - 获取帮助
3. Webhook 设置
bash
设置 webhook(使用您的服务器 URL)
python3 {baseDir}/scripts/telegram_business.py set-webhook https://your-domain.com/webhook/telegram
获取 webhook 信息
python3 {baseDir}/scripts/telegram_business.py get-webhook
删除 webhook(切换到轮询模式)
python3 {baseDir}/scripts/telegram_business.py delete-webhook
可用命令
消息发送
bash
发送文本
python3 {baseDir}/scripts/telegrambusiness.py send-message id> 您好!
使用 HTML 格式发送
python3 {baseDir}/scripts/telegrambusiness.py send-message id> 粗体 和 斜体 --html
使用 Markdown 格式发送
python3 {baseDir}/scripts/telegrambusiness.py send-message id> 粗体 和 斜体 --markdown
回复消息
python3 {baseDir}/scripts/telegrambusiness.py send-message id> 收到! --reply-to
内联键盘
bash
简单菜单(每行 2 个按钮)
python3 {baseDir}/scripts/telegrambusiness.py send-menu id> 选择一个选项: [
{text:选项 A,callbackdata:opta},
{text:选项 B,callbackdata:optb},
{text:选项 C,callbackdata:optc}
]
URL 按钮
python3 {baseDir}/scripts/telegrambusiness.py send-menu id> 访问我们: [
{text:🌐 网站,url:https://example.com},
{text:📸 Instagram,url:https://instagram.com/example}
]
回复回调查询(确认按钮按下)
python3 {baseDir}/scripts/telegrambusiness.py answer-callback query_id> 处理中...
编辑消息(按钮按下后更新)
python3 {baseDir}/scripts/telegrambusiness.py edit-message id> 已更新的文本!
潜在客户获取
bash
发送潜在客户获取表单(多步骤内联流程)
python3 {baseDir}/scripts/telegrambusiness.py send-lead-form id>
处理潜在客户数据(通过对话收集后)
python3 {baseDir}/scripts/telegrambusiness.py process-lead {chatid:123,name:张三,email:zhangsan@example.com,phone:+15551234567,interest:AI 自动化,source:telegram}
常见问题解答系统
bash
匹配问题到常见问题解答
python3 {baseDir}/scripts/telegram_business.py faq-match 你们的营业时间是?
发送常见问题解答菜单
python3 {baseDir}/scripts/telegrambusiness.py send-faq-menu id>
媒体
bash
发送照片
python3 {baseDir}/scripts/telegrambusiness.py send-photo id> https://example.com/image.jpg 此处为说明文字
发送文档
python3 {baseDir}/scripts/telegrambusiness.py send-document id> /path/to/file.pdf
发送名片
python3 {baseDir}/scripts/telegrambusiness.py send-contact id> +15551234567 张三 李
潜在客户获取流程
机器人引导用户完成多步骤表单:
- 1. 开始 → 带菜单按钮的欢迎消息
- 获取报价 → 询问姓名
- 用户发送姓名 → 询问邮箱
- 用户发送邮箱 → 询问电话(可选)
- 用户发送电话 → 询问服务兴趣(按钮)
- 用户选择服务 → 确认 + 感谢
- 潜在客户数据以 JSON 格式输出,用于 CRM 集成
与 CRM 集成
bash
从 Telegram 捕获潜在客户,评分,添加到 GHL
LEAD={name:张三,email:zhangsan@x.com,phone:+1555...,source:telegram}
SCORE=$(python3 ../lead-gen-pipeline/{baseDir}/scripts/lead_scorer.py $LEAD)
python3 ../ghl-crm/{baseDir}/scripts/ghl_api.py contacts create $LEAD
常见问题解答自动化
在脚本的 FAQ_DATABASE 中定义您的常见问题解答:
python
FAQ_DATABASE = [
{q: 你们的营业时间是?, a: 我们周一至周五上午 9 点至下午 6 点(美国东部时间)营业。, keywords: [时间, 营业, 工作时间]},
{q: 你们在哪里?, a: 纽约市主街 123 号, keywords: [位置, 地址, 哪里]},
{q: 费用是多少?, a: 套餐起价为每月 99 美元。回复定价获取详情。, keywords: [费用, 价格, 定价, 多少钱]},
]
常见问题解答匹配器使用关键词匹配 + 模糊相似度。如需 AI 驱动的匹配,可通过 LLM 进行管道处理。
支付集成
Telegram 通过支付提供商(Stripe 等)支持原生支付:
bash
发送发票
python3 {baseDir}/scripts/telegrambusiness.py send-invoice id> {
title: 咨询费,
description: 1 小时 AI 自动化咨询,
payload: consultation_001,
providertoken: STRIPETOKEN,
currency: USD,
prices: [{label: 咨询, amount: 9900}]
}
注意: amount 以最小货币单位表示(美元为美分)。99.00 美元 = 9900。
群组管理
bash
获取聊天信息
python3 {baseDir}/scripts/telegrambusiness.py get-chat id>
获取成员数量
python3 {baseDir}/scripts/telegrambusiness.py get-member-count id>
置顶消息
python3 {baseDir}/scripts/telegrambusiness.py pin-message id>
设置聊天描述
python3 {baseDir}/scripts/telegrambusiness.py set-description id> 欢迎来到我们的社区!
Webhook 负载处理
使用 webhook 时,传入的更新如下所示:
消息:
json
{updateid: 123, message: {chat: {id: 456}, from: {id: 789, firstname: 张三}, text: /start}}
回调(按钮按下):
json
{updateid: 124, callbackquery: {id: abc, data: book, message: {chat: {id: 456}}}}
使用以下命令解析:
bash
python3 {baseDir}/scripts/telegram_business.py parse-update
致谢
由 [M. Abidi](https://www.linked