whatsapp-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhatsApp Business Automation via Rube MCP
通过Rube MCP实现WhatsApp Business自动化
Automate WhatsApp Business operations through Composio's WhatsApp toolkit via Rube MCP.
通过Composio的WhatsApp工具包,借助Rube MCP自动化WhatsApp Business的运营操作。
Prerequisites
前提条件
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active WhatsApp connection via with toolkit
RUBE_MANAGE_CONNECTIONSwhatsapp - Always call first to get current tool schemas
RUBE_SEARCH_TOOLS - WhatsApp Business API account required (not regular WhatsApp)
- 必须已连接Rube MCP(需具备RUBE_SEARCH_TOOLS权限)
- 已通过完成WhatsApp连接,且工具包为
RUBE_MANAGE_CONNECTIONSwhatsapp - 请始终先调用以获取当前工具架构
RUBE_SEARCH_TOOLS - 需要WhatsApp Business API账号(非普通WhatsApp账号)
Setup
设置步骤
Get Rube MCP: Add as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
https://rube.app/mcp- Verify Rube MCP is available by confirming responds
RUBE_SEARCH_TOOLS - Call with toolkit
RUBE_MANAGE_CONNECTIONSwhatsapp - If connection is not ACTIVE, follow the returned auth link to complete WhatsApp Business setup
- Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加作为MCP服务器。无需API密钥——只需添加端点即可使用。
https://rube.app/mcp- 通过确认能正常响应,验证Rube MCP是否可用
RUBE_SEARCH_TOOLS - 调用并指定工具包为
RUBE_MANAGE_CONNECTIONSwhatsapp - 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成WhatsApp Business设置
- 在运行任何工作流之前,确认连接状态显示为ACTIVE
Core Workflows
核心工作流
1. Send a Text Message
1. 发送文本消息
When to use: User wants to send a text message to a WhatsApp contact
Tool sequence:
- - List available business phone numbers [Prerequisite]
WHATSAPP_GET_PHONE_NUMBERS - - Send a text message [Required]
WHATSAPP_SEND_MESSAGE
Key parameters:
- : Recipient phone number in international format (e.g., '+14155551234')
to - : Message text content
body - : Business phone number ID to send from
phone_number_id
Pitfalls:
- Phone numbers must be in international E.164 format with country code
- Messages outside the 24-hour window require approved templates
- The 24-hour window starts when the customer last messaged you
- Business-initiated conversations require template messages first
适用场景:用户需要向WhatsApp联系人发送文本消息
工具执行顺序:
- - 列出可用的企业电话号码【前提步骤】
WHATSAPP_GET_PHONE_NUMBERS - - 发送文本消息【必需步骤】
WHATSAPP_SEND_MESSAGE
关键参数:
- : 收件人电话号码,需采用国际格式(例如:'+14155551234')
to - : 消息文本内容
body - : 发送消息所用的企业电话号码ID
phone_number_id
注意事项:
- 电话号码必须采用带国家代码的国际E.164格式
- 超出24小时对话窗口的消息需使用已获批的模板
- 24小时窗口从客户最后一次发送消息时开始计算
- 企业主动发起的对话必须先使用模板消息
2. Send Template Messages
2. 发送模板消息
When to use: User wants to send pre-approved template messages for outbound communication
Tool sequence:
- - List available templates [Prerequisite]
WHATSAPP_GET_MESSAGE_TEMPLATES - - Check template approval status [Optional]
WHATSAPP_GET_TEMPLATE_STATUS - - Send the template message [Required]
WHATSAPP_SEND_TEMPLATE_MESSAGE
Key parameters:
- : Name of the approved template
template_name - : Template language (e.g., 'en_US')
language_code - : Recipient phone number
to - : Template variable values and parameters
components
Pitfalls:
- Templates must be approved by Meta before use
- Template variables must match the expected count and format
- Sending unapproved or rejected templates returns errors
- Language code must match an approved translation of the template
适用场景:用户需要发送预先获批的模板消息以进行外呼沟通
工具执行顺序:
- - 列出可用模板【前提步骤】
WHATSAPP_GET_MESSAGE_TEMPLATES - - 检查模板审批状态【可选步骤】
WHATSAPP_GET_TEMPLATE_STATUS - - 发送模板消息【必需步骤】
WHATSAPP_SEND_TEMPLATE_MESSAGE
关键参数:
- : 已获批模板的名称
template_name - : 模板语言(例如:'en_US')
language_code - : 收件人电话号码
to - : 模板变量值及参数
components
注意事项:
- 模板必须经过Meta审批后方可使用
- 模板变量的数量和格式必须与预期一致
- 发送未获批或已被拒绝的模板会返回错误
- 语言代码必须与模板的获批翻译版本匹配
3. Send Media Messages
3. 发送媒体消息
When to use: User wants to send images, documents, or other media
Tool sequence:
- - Upload media to WhatsApp servers [Required]
WHATSAPP_UPLOAD_MEDIA - - Send media using the uploaded media ID [Required] OR
WHATSAPP_SEND_MEDIA_BY_ID - - Send media using a public URL [Alternative]
WHATSAPP_SEND_MEDIA
Key parameters:
- : Public URL of the media (for SEND_MEDIA)
media_url - : ID from upload response (for SEND_MEDIA_BY_ID)
media_id - : Media type ('image', 'document', 'audio', 'video', 'sticker')
type - : Optional caption for the media
caption
Pitfalls:
- Uploaded media IDs are temporary and expire after a period
- Media size limits vary by type (images: 5MB, videos: 16MB, documents: 100MB)
- Supported formats: images (JPEG, PNG), videos (MP4, 3GPP), documents (PDF, etc.)
- SEND_MEDIA requires a publicly accessible HTTPS URL
适用场景:用户需要发送图片、文档或其他媒体内容
工具执行顺序:
- - 将媒体上传至WhatsApp服务器【必需步骤】
WHATSAPP_UPLOAD_MEDIA - - 使用上传后的媒体ID发送媒体【必需步骤】 或
WHATSAPP_SEND_MEDIA_BY_ID - - 使用公共URL发送媒体【替代方案】
WHATSAPP_SEND_MEDIA
关键参数:
- : 媒体的公共URL(适用于SEND_MEDIA)
media_url - : 上传响应中返回的媒体ID(适用于SEND_MEDIA_BY_ID)
media_id - : 媒体类型('image'、'document'、'audio'、'video'、'sticker')
type - : 媒体的可选说明文字
caption
注意事项:
- 上传后的媒体ID为临时有效,会在一段时间后过期
- 不同类型的媒体有不同的大小限制(图片:5MB,视频:16MB,文档:100MB)
- 支持的格式:图片(JPEG、PNG)、视频(MP4、3GPP)、文档(PDF等)
- SEND_MEDIA需要可公开访问的HTTPS URL
4. Reply to Messages
4. 回复消息
When to use: User wants to reply to an incoming WhatsApp message
Tool sequence:
- - Send a reply to a specific message [Required]
WHATSAPP_SEND_REPLY
Key parameters:
- : ID of the message being replied to
message_id - : Recipient phone number
to - : Reply text content
body
Pitfalls:
- message_id must be from a message received within the 24-hour window
- Replies appear as quoted messages in the conversation
- The original message must still exist (not deleted) for the quote to display
适用场景:用户需要回复收到的WhatsApp消息
工具执行顺序:
- - 回复特定消息【必需步骤】
WHATSAPP_SEND_REPLY
关键参数:
- : 待回复消息的ID
message_id - : 收件人电话号码
to - : 回复的文本内容
body
注意事项:
- message_id必须来自24小时对话窗口内收到的消息
- 回复会以引用消息的形式显示在对话中
- 原始消息必须仍存在(未被删除)才能正常显示引用内容
5. Manage Business Profile and Templates
5. 管理企业资料与模板
When to use: User wants to view or manage their WhatsApp Business profile
Tool sequence:
- - Get business profile details [Optional]
WHATSAPP_GET_BUSINESS_PROFILE - - List registered phone numbers [Optional]
WHATSAPP_GET_PHONE_NUMBERS - - Get details for a specific number [Optional]
WHATSAPP_GET_PHONE_NUMBER - - Create a new template [Optional]
WHATSAPP_CREATE_MESSAGE_TEMPLATE - - List all templates [Optional]
WHATSAPP_GET_MESSAGE_TEMPLATES
Key parameters:
- : Business phone number ID
phone_number_id - : Name for the new template
template_name - : Template category (MARKETING, UTILITY, AUTHENTICATION)
category - : Template language code
language
Pitfalls:
- New templates require Meta review before they can be used
- Template names must be lowercase with underscores (no spaces)
- Category affects pricing and approval criteria
- Templates have specific formatting requirements for headers, body, and buttons
适用场景:用户需要查看或管理其WhatsApp企业资料
工具执行顺序:
- - 获取企业资料详情【可选步骤】
WHATSAPP_GET_BUSINESS_PROFILE - - 列出已注册的电话号码【可选步骤】
WHATSAPP_GET_PHONE_NUMBERS - - 获取特定号码的详情【可选步骤】
WHATSAPP_GET_PHONE_NUMBER - - 创建新模板【可选步骤】
WHATSAPP_CREATE_MESSAGE_TEMPLATE - - 列出所有模板【可选步骤】
WHATSAPP_GET_MESSAGE_TEMPLATES
关键参数:
- : 企业电话号码ID
phone_number_id - : 新模板的名称
template_name - : 模板类别(MARKETING、UTILITY、AUTHENTICATION)
category - : 模板语言代码
language
注意事项:
- 新模板需要经过Meta审核后才能使用
- 模板名称必须为小写字母,以下划线分隔(不能包含空格)
- 模板类别会影响定价和审核标准
- 模板的标题、正文和按钮有特定的格式要求
6. Share Contacts
6. 分享联系人
When to use: User wants to send contact information via WhatsApp
Tool sequence:
- - Send contact cards [Required]
WHATSAPP_SEND_CONTACTS
Key parameters:
- : Recipient phone number
to - : Array of contact objects with name, phone, email details
contacts
Pitfalls:
- Contact objects must follow the WhatsApp Business API contact schema
- At least a name field is required for each contact
- Phone numbers in contacts should include country codes
适用场景:用户需要通过WhatsApp发送联系人信息
工具执行顺序:
- - 发送联系人卡片【必需步骤】
WHATSAPP_SEND_CONTACTS
关键参数:
- : 收件人电话号码
to - : 包含姓名、电话、邮箱详情的联系人对象数组
contacts
注意事项:
- 联系人对象必须遵循WhatsApp Business API的联系人架构
- 每个联系人至少需要包含姓名字段
- 联系人中的电话号码应包含国家代码
Common Patterns
通用模式
24-Hour Messaging Window
24小时消息窗口
- Customers must message you first to open a conversation window
- Within 24 hours of their last message, you can send free-form messages
- After 24 hours, only approved template messages can be sent
- Template messages can re-open the conversation window
- 客户必须先发送消息才能开启对话窗口
- 在客户最后一条消息的24小时内,可发送自由格式消息
- 24小时后,仅能发送已获批的模板消息
- 模板消息可重新开启对话窗口
Phone Number Resolution
电话号码解析
1. Call WHATSAPP_GET_PHONE_NUMBERS
2. Extract phone_number_id for your business number
3. Use phone_number_id in all send operations1. 调用WHATSAPP_GET_PHONE_NUMBERS
2. 提取企业号码对应的phone_number_id
3. 在所有发送操作中使用该phone_number_idMedia Upload Flow
媒体上传流程
1. Call WHATSAPP_UPLOAD_MEDIA with the file
2. Extract media_id from response
3. Call WHATSAPP_SEND_MEDIA_BY_ID with media_id
4. OR use WHATSAPP_SEND_MEDIA with a public URL directly1. 调用WHATSAPP_UPLOAD_MEDIA上传文件
2. 从响应中提取media_id
3. 调用WHATSAPP_SEND_MEDIA_BY_ID并传入media_id
4. 或直接使用WHATSAPP_SEND_MEDIA并传入公共URLKnown Pitfalls
已知注意事项
Phone Number Format:
- Always use E.164 format: +[country code][number] (e.g., '+14155551234')
- Do not include dashes, spaces, or parentheses
- Country code is required; local numbers without it will fail
Messaging Restrictions:
- Business-initiated messages require templates outside the 24-hour window
- Template messages cost money per conversation
- Rate limits apply per phone number and per account
Media Handling:
- Uploaded media expires; use promptly after upload
- Media URLs must be publicly accessible HTTPS
- Stickers have specific requirements (WebP format, 512x512 pixels)
Template Management:
- Template review can take up to 24 hours
- Rejected templates need to be fixed and resubmitted
- Template variables use double curly braces: {{1}}, {{2}}, etc.
电话号码格式:
- 请始终使用E.164格式:+[国家代码][号码](例如:'+14155551234')
- 请勿包含短横线、空格或括号
- 必须包含国家代码;无国家代码的本地号码会导致操作失败
消息限制:
- 在24小时窗口外,企业主动发起的消息必须使用模板
- 模板消息按对话次数收费
- 每个电话号码和账号都有调用频率限制
媒体处理:
- 上传的媒体会过期,请在上传后及时使用
- 媒体URL必须是可公开访问的HTTPS链接
- 贴纸有特定要求(WebP格式,512x512像素)
模板管理:
- 模板审核最长可能需要24小时
- 被拒绝的模板需要修改后重新提交
- 模板变量使用双大括号:{{1}}, {{2}}等
Quick Reference
快速参考
| Task | Tool Slug | Key Params |
|---|---|---|
| Send message | WHATSAPP_SEND_MESSAGE | to, body |
| Send template | WHATSAPP_SEND_TEMPLATE_MESSAGE | template_name, to, language_code |
| Upload media | WHATSAPP_UPLOAD_MEDIA | (file params) |
| Send media by ID | WHATSAPP_SEND_MEDIA_BY_ID | media_id, to, type |
| Send media by URL | WHATSAPP_SEND_MEDIA | media_url, to, type |
| Reply to message | WHATSAPP_SEND_REPLY | message_id, to, body |
| Send contacts | WHATSAPP_SEND_CONTACTS | to, contacts |
| Get media | WHATSAPP_GET_MEDIA | media_id |
| List phone numbers | WHATSAPP_GET_PHONE_NUMBERS | (none) |
| Get phone number | WHATSAPP_GET_PHONE_NUMBER | phone_number_id |
| Get business profile | WHATSAPP_GET_BUSINESS_PROFILE | phone_number_id |
| Create template | WHATSAPP_CREATE_MESSAGE_TEMPLATE | template_name, category, language |
| List templates | WHATSAPP_GET_MESSAGE_TEMPLATES | (none) |
| Check template status | WHATSAPP_GET_TEMPLATE_STATUS | template_id |
| 任务 | 工具标识 | 关键参数 |
|---|---|---|
| 发送消息 | WHATSAPP_SEND_MESSAGE | to, body |
| 发送模板消息 | WHATSAPP_SEND_TEMPLATE_MESSAGE | template_name, to, language_code |
| 上传媒体 | WHATSAPP_UPLOAD_MEDIA | (文件参数) |
| 通过ID发送媒体 | WHATSAPP_SEND_MEDIA_BY_ID | media_id, to, type |
| 通过URL发送媒体 | WHATSAPP_SEND_MEDIA | media_url, to, type |
| 回复消息 | WHATSAPP_SEND_REPLY | message_id, to, body |
| 发送联系人 | WHATSAPP_SEND_CONTACTS | to, contacts |
| 获取媒体 | WHATSAPP_GET_MEDIA | media_id |
| 列出电话号码 | WHATSAPP_GET_PHONE_NUMBERS | (无) |
| 获取电话号码详情 | WHATSAPP_GET_PHONE_NUMBER | phone_number_id |
| 获取企业资料 | WHATSAPP_GET_BUSINESS_PROFILE | phone_number_id |
| 创建模板 | WHATSAPP_CREATE_MESSAGE_TEMPLATE | template_name, category, language |
| 列出模板 | WHATSAPP_GET_MESSAGE_TEMPLATES | (无) |
| 检查模板状态 | WHATSAPP_GET_TEMPLATE_STATUS | template_id |