返回顶部
w

whatsapp-businessWhatsApp商业版

|

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.3
安全检测
已通过
20,582
下载量
免费
免费
57
收藏
概述
安装方式
版本历史

whatsapp-business

WhatsApp Business

通过托管OAuth认证访问WhatsApp Business API。发送消息、管理消息模板、处理媒体文件,并通过WhatsApp与客户互动。

快速开始

bash

发送文本消息


python < import urllib.request, os, json
data = json.dumps({messaging_product: whatsapp, to: 1234567890, type: text, text: {body: 来自WhatsApp Business的问候!}}).encode()
req = urllib.request.Request(https://gateway.maton.ai/whatsapp-business/v21.0/PHONENUMBERID/messages, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

基础URL

https://gateway.maton.ai/whatsapp-business/{native-api-path}

将{native-api-path}替换为实际的WhatsApp Business API端点路径。网关将请求代理到graph.facebook.com,并自动注入您的OAuth令牌。

认证

所有请求都需要在Authorization头中携带Maton API密钥:

Authorization: Bearer $MATONAPIKEY

环境变量: 将您的API密钥设置为MATONAPIKEY:

bash
export MATONAPIKEY=YOURAPIKEY

获取您的API密钥

  1. 1. 登录或注册账号,访问maton.ai
  2. 前往maton.ai/settings
  3. 复制您的API密钥

连接管理

在https://ctrl.maton.ai管理您的WhatsApp Business OAuth连接。

列出连接

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections?app=whatsapp-business&status=ACTIVE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

创建连接

bash
python < import urllib.request, os, json
data = json.dumps({app: whatsapp-business}).encode()
req = urllib.request.Request(https://ctrl.maton.ai/connections, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

获取连接

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id})
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

响应:
json
{
connection: {
connection_id: 21fd90f9-5935-43cd-b6c8-bde9d915ca80,
status: ACTIVE,
creation_time: 2025-12-08T07:20:53.488460Z,
lastupdatedtime: 2026-01-31T20:03:32.593153Z,
url: https://connect.maton.ai/?session_token=...,
app: whatsapp-business,
metadata: {}
}
}

在浏览器中打开返回的url以完成OAuth授权。

删除连接

bash
python < import urllib.request, os, json
req = urllib.request.Request(https://ctrl.maton.ai/connections/{connection_id}, method=DELETE)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

指定连接

如果您有多个WhatsApp Business连接,请使用Maton-Connection头指定要使用的连接:

bash
python < import urllib.request, os, json
data = json.dumps({messaging_product: whatsapp, to: 1234567890, type: text, text: {body: 你好!}}).encode()
req = urllib.request.Request(https://gateway.maton.ai/whatsapp-business/v21.0/PHONENUMBERID/messages, data=data, method=POST)
req.addheader(Authorization, fBearer {os.environ[MATONAPI_KEY]})
req.add_header(Maton-Connection, 21fd90f9-5935-43cd-b6c8-bde9d915ca80)
req.add_header(Content-Type, application/json)
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF

如果省略,网关将使用默认(最旧)的活动连接。

API参考

消息

发送文本消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
recipient_type: individual,
to: 1234567890,
type: text,
text: {
preview_url: true,
body: 你好!请查看 https://example.com
}
}

发送模板消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: template,
template: {
name: hello_world,
language: {
code: en_US
},
components: [
{
type: body,
parameters: [
{type: text, text: 张三}
]
}
]
}
}

发送图片消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: image,
image: {
link: https://example.com/image.jpg,
caption: 看看这张图片!
}
}

发送文档消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: document,
document: {
link: https://example.com/document.pdf,
caption: 这是文档,
filename: report.pdf
}
}

发送视频消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: video,
video: {
link: https://example.com/video.mp4,
caption: 观看此视频
}
}

发送音频消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: audio,
audio: {
link: https://example.com/audio.mp3
}
}

发送位置消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: location,
location: {
latitude: 37.7749,
longitude: -122.4194,
name: 旧金山,
address: 美国加利福尼亚州旧金山
}
}

发送联系人消息

bash
POST /whatsapp-business/v21.0/{phonenumberid}/messages
Content-Type: application/json

{
messaging_product: whatsapp,
to: 1234567890,
type: contacts,
contacts: [
{
name: {
formatted_name: 张三,
first_name: 三,
last_name: 张
},
phones: [
{phone: +1234567890, type: MOBILE}
]
}
]
}

发送交互式

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 whatsapp-business-1776364632 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 whatsapp-business-1776364632 技能

通过命令行安装

skillhub install whatsapp-business-1776364632

下载

⬇ 下载 whatsapp-business v1.0.3(免费)

文件大小: 5.58 KB | 发布时间: 2026-4-17 14:23

v1.0.3 最新 2026-4-17 14:23
- Added metadata specifying required environment variable: MATON_API_KEY.
- Included emoji indicator in the metadata for identification.
- No changes to code or core functionality.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部