whatsapp-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WhatsApp 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
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    whatsapp
  • Always call
    RUBE_SEARCH_TOOLS
    first to get current tool schemas
  • WhatsApp Business API account required (not regular WhatsApp)
  • 必须已连接Rube MCP(需具备RUBE_SEARCH_TOOLS权限)
  • 已通过
    RUBE_MANAGE_CONNECTIONS
    完成WhatsApp连接,且工具包为
    whatsapp
  • 请始终先调用
    RUBE_SEARCH_TOOLS
    以获取当前工具架构
  • 需要WhatsApp Business API账号(非普通WhatsApp账号)

Setup

设置步骤

Get Rube MCP: Add
https://rube.app/mcp
as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
  1. Verify Rube MCP is available by confirming
    RUBE_SEARCH_TOOLS
    responds
  2. Call
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    whatsapp
  3. If connection is not ACTIVE, follow the returned auth link to complete WhatsApp Business setup
  4. Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加
https://rube.app/mcp
作为MCP服务器。无需API密钥——只需添加端点即可使用。
  1. 通过确认
    RUBE_SEARCH_TOOLS
    能正常响应,验证Rube MCP是否可用
  2. 调用
    RUBE_MANAGE_CONNECTIONS
    并指定工具包为
    whatsapp
  3. 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成WhatsApp Business设置
  4. 在运行任何工作流之前,确认连接状态显示为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:
  1. WHATSAPP_GET_PHONE_NUMBERS
    - List available business phone numbers [Prerequisite]
  2. WHATSAPP_SEND_MESSAGE
    - Send a text message [Required]
Key parameters:
  • to
    : Recipient phone number in international format (e.g., '+14155551234')
  • body
    : Message text content
  • phone_number_id
    : Business phone number ID to send from
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联系人发送文本消息
工具执行顺序:
  1. WHATSAPP_GET_PHONE_NUMBERS
    - 列出可用的企业电话号码【前提步骤】
  2. WHATSAPP_SEND_MESSAGE
    - 发送文本消息【必需步骤】
关键参数:
  • to
    : 收件人电话号码,需采用国际格式(例如:'+14155551234')
  • body
    : 消息文本内容
  • phone_number_id
    : 发送消息所用的企业电话号码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:
  1. WHATSAPP_GET_MESSAGE_TEMPLATES
    - List available templates [Prerequisite]
  2. WHATSAPP_GET_TEMPLATE_STATUS
    - Check template approval status [Optional]
  3. WHATSAPP_SEND_TEMPLATE_MESSAGE
    - Send the template message [Required]
Key parameters:
  • template_name
    : Name of the approved template
  • language_code
    : Template language (e.g., 'en_US')
  • to
    : Recipient phone number
  • components
    : Template variable values and parameters
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
适用场景:用户需要发送预先获批的模板消息以进行外呼沟通
工具执行顺序:
  1. WHATSAPP_GET_MESSAGE_TEMPLATES
    - 列出可用模板【前提步骤】
  2. WHATSAPP_GET_TEMPLATE_STATUS
    - 检查模板审批状态【可选步骤】
  3. WHATSAPP_SEND_TEMPLATE_MESSAGE
    - 发送模板消息【必需步骤】
关键参数:
  • template_name
    : 已获批模板的名称
  • language_code
    : 模板语言(例如:'en_US')
  • to
    : 收件人电话号码
  • components
    : 模板变量值及参数
注意事项:
  • 模板必须经过Meta审批后方可使用
  • 模板变量的数量和格式必须与预期一致
  • 发送未获批或已被拒绝的模板会返回错误
  • 语言代码必须与模板的获批翻译版本匹配

3. Send Media Messages

3. 发送媒体消息

When to use: User wants to send images, documents, or other media
Tool sequence:
  1. WHATSAPP_UPLOAD_MEDIA
    - Upload media to WhatsApp servers [Required]
  2. WHATSAPP_SEND_MEDIA_BY_ID
    - Send media using the uploaded media ID [Required] OR
  3. WHATSAPP_SEND_MEDIA
    - Send media using a public URL [Alternative]
Key parameters:
  • media_url
    : Public URL of the media (for SEND_MEDIA)
  • media_id
    : ID from upload response (for SEND_MEDIA_BY_ID)
  • type
    : Media type ('image', 'document', 'audio', 'video', 'sticker')
  • caption
    : Optional caption for the media
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
适用场景:用户需要发送图片、文档或其他媒体内容
工具执行顺序:
  1. WHATSAPP_UPLOAD_MEDIA
    - 将媒体上传至WhatsApp服务器【必需步骤】
  2. WHATSAPP_SEND_MEDIA_BY_ID
    - 使用上传后的媒体ID发送媒体【必需步骤】 或
  3. WHATSAPP_SEND_MEDIA
    - 使用公共URL发送媒体【替代方案】
关键参数:
  • media_url
    : 媒体的公共URL(适用于SEND_MEDIA)
  • media_id
    : 上传响应中返回的媒体ID(适用于SEND_MEDIA_BY_ID)
  • type
    : 媒体类型('image'、'document'、'audio'、'video'、'sticker')
  • 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:
  1. WHATSAPP_SEND_REPLY
    - Send a reply to a specific message [Required]
Key parameters:
  • message_id
    : ID of the message being replied to
  • to
    : Recipient phone number
  • body
    : Reply text content
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消息
工具执行顺序:
  1. WHATSAPP_SEND_REPLY
    - 回复特定消息【必需步骤】
关键参数:
  • message_id
    : 待回复消息的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:
  1. WHATSAPP_GET_BUSINESS_PROFILE
    - Get business profile details [Optional]
  2. WHATSAPP_GET_PHONE_NUMBERS
    - List registered phone numbers [Optional]
  3. WHATSAPP_GET_PHONE_NUMBER
    - Get details for a specific number [Optional]
  4. WHATSAPP_CREATE_MESSAGE_TEMPLATE
    - Create a new template [Optional]
  5. WHATSAPP_GET_MESSAGE_TEMPLATES
    - List all templates [Optional]
Key parameters:
  • phone_number_id
    : Business phone number ID
  • template_name
    : Name for the new template
  • category
    : Template category (MARKETING, UTILITY, AUTHENTICATION)
  • language
    : Template language code
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企业资料
工具执行顺序:
  1. WHATSAPP_GET_BUSINESS_PROFILE
    - 获取企业资料详情【可选步骤】
  2. WHATSAPP_GET_PHONE_NUMBERS
    - 列出已注册的电话号码【可选步骤】
  3. WHATSAPP_GET_PHONE_NUMBER
    - 获取特定号码的详情【可选步骤】
  4. WHATSAPP_CREATE_MESSAGE_TEMPLATE
    - 创建新模板【可选步骤】
  5. WHATSAPP_GET_MESSAGE_TEMPLATES
    - 列出所有模板【可选步骤】
关键参数:
  • phone_number_id
    : 企业电话号码ID
  • template_name
    : 新模板的名称
  • category
    : 模板类别(MARKETING、UTILITY、AUTHENTICATION)
  • language
    : 模板语言代码
注意事项:
  • 新模板需要经过Meta审核后才能使用
  • 模板名称必须为小写字母,以下划线分隔(不能包含空格)
  • 模板类别会影响定价和审核标准
  • 模板的标题、正文和按钮有特定的格式要求

6. Share Contacts

6. 分享联系人

When to use: User wants to send contact information via WhatsApp
Tool sequence:
  1. WHATSAPP_SEND_CONTACTS
    - Send contact cards [Required]
Key parameters:
  • to
    : Recipient phone number
  • contacts
    : Array of contact objects with name, phone, email details
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发送联系人信息
工具执行顺序:
  1. 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 operations
1. 调用WHATSAPP_GET_PHONE_NUMBERS
2. 提取企业号码对应的phone_number_id
3. 在所有发送操作中使用该phone_number_id

Media 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 directly
1. 调用WHATSAPP_UPLOAD_MEDIA上传文件
2. 从响应中提取media_id
3. 调用WHATSAPP_SEND_MEDIA_BY_ID并传入media_id
4. 或直接使用WHATSAPP_SEND_MEDIA并传入公共URL

Known 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

快速参考

TaskTool SlugKey Params
Send messageWHATSAPP_SEND_MESSAGEto, body
Send templateWHATSAPP_SEND_TEMPLATE_MESSAGEtemplate_name, to, language_code
Upload mediaWHATSAPP_UPLOAD_MEDIA(file params)
Send media by IDWHATSAPP_SEND_MEDIA_BY_IDmedia_id, to, type
Send media by URLWHATSAPP_SEND_MEDIAmedia_url, to, type
Reply to messageWHATSAPP_SEND_REPLYmessage_id, to, body
Send contactsWHATSAPP_SEND_CONTACTSto, contacts
Get mediaWHATSAPP_GET_MEDIAmedia_id
List phone numbersWHATSAPP_GET_PHONE_NUMBERS(none)
Get phone numberWHATSAPP_GET_PHONE_NUMBERphone_number_id
Get business profileWHATSAPP_GET_BUSINESS_PROFILEphone_number_id
Create templateWHATSAPP_CREATE_MESSAGE_TEMPLATEtemplate_name, category, language
List templatesWHATSAPP_GET_MESSAGE_TEMPLATES(none)
Check template statusWHATSAPP_GET_TEMPLATE_STATUStemplate_id
任务工具标识关键参数
发送消息WHATSAPP_SEND_MESSAGEto, body
发送模板消息WHATSAPP_SEND_TEMPLATE_MESSAGEtemplate_name, to, language_code
上传媒体WHATSAPP_UPLOAD_MEDIA(文件参数)
通过ID发送媒体WHATSAPP_SEND_MEDIA_BY_IDmedia_id, to, type
通过URL发送媒体WHATSAPP_SEND_MEDIAmedia_url, to, type
回复消息WHATSAPP_SEND_REPLYmessage_id, to, body
发送联系人WHATSAPP_SEND_CONTACTSto, contacts
获取媒体WHATSAPP_GET_MEDIAmedia_id
列出电话号码WHATSAPP_GET_PHONE_NUMBERS(无)
获取电话号码详情WHATSAPP_GET_PHONE_NUMBERphone_number_id
获取企业资料WHATSAPP_GET_BUSINESS_PROFILEphone_number_id
创建模板WHATSAPP_CREATE_MESSAGE_TEMPLATEtemplate_name, category, language
列出模板WHATSAPP_GET_MESSAGE_TEMPLATES(无)
检查模板状态WHATSAPP_GET_TEMPLATE_STATUStemplate_id