send-message
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSend Message
发送消息
When to Use
使用场景
Use this skill when building code to send messages through the Zavu API. Covers channel selection, message types, and error handling.
当你编写代码通过Zavu API发送消息时,可使用该技能。内容涵盖渠道选择、消息类型及错误处理。
Channel Selection Decision Tree
渠道选择决策树
Is recipient an email address?
-> YES: channel = "email" (requires KYC verification)
Is message type non-text (image, video, buttons, list, template, etc.)?
-> YES: channel = "whatsapp" (auto-selected)
Need voice call / TTS?
-> YES: channel = "voice"
Need guaranteed delivery to specific channel?
-> YES: channel = "sms" | "whatsapp" | "telegram"
Want cost-optimized routing?
-> YES: channel = "auto" (ML-powered smart routing)
Default?
-> channel = "sms" (or omit for default)Is recipient an email address?
-> YES: channel = "email" (requires KYC verification)
Is message type non-text (image, video, buttons, list, template, etc.)?
-> YES: channel = "whatsapp" (auto-selected)
Need voice call / TTS?
-> YES: channel = "voice"
Need guaranteed delivery to specific channel?
-> YES: channel = "sms" | "whatsapp" | "telegram"
Want cost-optimized routing?
-> YES: channel = "auto" (ML-powered smart routing)
Default?
-> channel = "sms" (or omit for default)Basic Messages
基础消息
SMS (default)
短信(SMS,默认渠道)
TypeScript:
typescript
const result = await zavu.messages.send({
to: "+14155551234",
text: "Your verification code is 123456",
});
console.log(result.message.id);Python:
python
result = zavu.messages.send(
to="+14155551234",
text="Your verification code is 123456",
)
print(result.message.id)TypeScript:
typescript
const result = await zavu.messages.send({
to: "+14155551234",
text: "Your verification code is 123456",
});
console.log(result.message.id);Python:
python
result = zavu.messages.send(
to="+14155551234",
text="Your verification code is 123456",
)
print(result.message.id)WhatsApp Text
WhatsApp 文本消息
typescript
const result = await zavu.messages.send({
to: "+14155551234",
channel: "whatsapp",
text: "Hello from Zavu!",
});typescript
const result = await zavu.messages.send({
to: "+14155551234",
channel: "whatsapp",
text: "Hello from Zavu!",
});邮件
typescript
const result = await zavu.messages.send({
to: "user@example.com",
channel: "email",
subject: "Your order has shipped",
text: "Hi John, your order #12345 has shipped.",
htmlBody: "<h1>Order Shipped</h1><p>Your order #12345 has shipped.</p>",
replyTo: "support@example.com",
});typescript
const result = await zavu.messages.send({
to: "user@example.com",
channel: "email",
subject: "Your order has shipped",
text: "Hi John, your order #12345 has shipped.",
htmlBody: "<h1>Order Shipped</h1><p>Your order #12345 has shipped.</p>",
replyTo: "support@example.com",
});Voice (Text-to-Speech)
语音(文本转语音,TTS)
typescript
const result = await zavu.messages.send({
to: "+14155551234",
channel: "voice",
text: "Your verification code is 1 2 3 4 5 6",
voiceLanguage: "en-US", // optional, auto-detected from country code
});typescript
const result = await zavu.messages.send({
to: "+14155551234",
channel: "voice",
text: "Your verification code is 1 2 3 4 5 6",
voiceLanguage: "en-US", // optional, auto-detected from country code
});WhatsApp Rich Messages
WhatsApp 富媒体消息
Image
图片
typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "image",
text: "Check out this product!", // caption
content: { mediaUrl: "https://example.com/image.jpg" },
});typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "image",
text: "Check out this product!", // caption
content: { mediaUrl: "https://example.com/image.jpg" },
});Document
文档
typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "document",
content: {
mediaUrl: "https://example.com/invoice.pdf",
filename: "invoice.pdf",
},
});typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "document",
content: {
mediaUrl: "https://example.com/invoice.pdf",
filename: "invoice.pdf",
},
});Video / Audio
视频 / 音频
typescript
// Video
await zavu.messages.send({
to: "+14155551234",
messageType: "video",
text: "Watch this!",
content: { mediaUrl: "https://example.com/video.mp4" },
});
// Audio
await zavu.messages.send({
to: "+14155551234",
messageType: "audio",
content: { mediaUrl: "https://example.com/audio.mp3" },
});typescript
// Video
await zavu.messages.send({
to: "+14155551234",
messageType: "video",
text: "Watch this!",
content: { mediaUrl: "https://example.com/video.mp4" },
});
// Audio
await zavu.messages.send({
to: "+14155551234",
messageType: "audio",
content: { mediaUrl: "https://example.com/audio.mp3" },
});Interactive Buttons (max 3)
交互式按钮(最多3个)
typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "buttons",
text: "How would you rate your experience?",
content: {
buttons: [
{ id: "great", title: "Great!" },
{ id: "okay", title: "It was okay" },
{ id: "poor", title: "Not good" },
],
},
});typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "buttons",
text: "How would you rate your experience?",
content: {
buttons: [
{ id: "great", title: "Great!" },
{ id: "okay", title: "It was okay" },
{ id: "poor", title: "Not good" },
],
},
});List Message
列表消息
typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "list",
text: "Select an option:",
content: {
listButton: "View Options",
sections: [{
title: "Products",
rows: [
{ id: "prod_1", title: "Product A", description: "$10.00" },
{ id: "prod_2", title: "Product B", description: "$20.00" },
],
}],
},
});typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "list",
text: "Select an option:",
content: {
listButton: "View Options",
sections: [{
title: "Products",
rows: [
{ id: "prod_1", title: "Product A", description: "$10.00" },
{ id: "prod_2", title: "Product B", description: "$20.00" },
],
}],
},
});Template Message
模板消息
typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "template",
content: {
templateId: "tpl_abc123",
templateVariables: { "1": "John", "2": "ORD-12345" },
},
});typescript
await zavu.messages.send({
to: "+14155551234",
messageType: "template",
content: {
templateId: "tpl_abc123",
templateVariables: { "1": "John", "2": "ORD-12345" },
},
});Reaction
消息反应
typescript
await zavu.messages.react({
messageId: "msg_abc123",
emoji: "\ud83d\udc4d",
});typescript
await zavu.messages.react({
messageId: "msg_abc123",
emoji: "\ud83d\udc4d",
});Sender Override
自定义发送方
typescript
await zavu.messages.send({
to: "+14155551234",
text: "Hello!",
'Zavu-Sender': "snd_abc123",
});typescript
await zavu.messages.send({
to: "+14155551234",
text: "Hello!",
'Zavu-Sender': "snd_abc123",
});Idempotency
幂等性
typescript
await zavu.messages.send({
to: "+14155551234",
text: "Payment confirmed",
idempotencyKey: "payment_confirm_order_123",
});typescript
await zavu.messages.send({
to: "+14155551234",
text: "Payment confirmed",
idempotencyKey: "payment_confirm_order_123",
});Get Status & List Messages
获取消息状态与消息列表
typescript
// Get single message
const msg = await zavu.messages.get({ messageId: "msg_abc123" });
console.log(msg.message.status); // queued | sending | sent | delivered | failed
// List with filters + pagination
let cursor: string | undefined;
do {
const result = await zavu.messages.list({ status: "delivered", limit: 50, cursor });
for (const message of result.items) {
console.log(message.id, message.status);
}
cursor = result.nextCursor ?? undefined;
} while (cursor);typescript
// Get single message
const msg = await zavu.messages.get({ messageId: "msg_abc123" });
console.log(msg.message.status); // queued | sending | sent | delivered | failed
// List with filters + pagination
let cursor: string | undefined;
do {
const result = await zavu.messages.list({ status: "delivered", limit: 50, cursor });
for (const message of result.items) {
console.log(message.id, message.status);
}
cursor = result.nextCursor ?? undefined;
} while (cursor);Common Errors
常见错误
| Error Code | Meaning | Fix |
|---|---|---|
| 24h window not open | Use template message instead |
| Message has unverified URLs | Submit URLs via |
| URL shortener detected | Use full destination URL |
| Email needs KYC | Complete verification in dashboard |
| Unverified account + URLs | Complete KYC verification |
| 错误代码 | 含义 | 解决方法 |
|---|---|---|
| 24小时发送窗口已关闭 | 改用模板消息 |
| 消息包含未验证的URL | 先通过 |
| 检测到URL缩短服务 | 使用完整的目标URL |
| 邮件功能需完成KYC验证 | 在控制台完成验证流程 |
| 账户未验证且包含URL | 完成KYC验证 |
Constraints
限制条件
- Button titles: max 20 chars, max 3 buttons
- List row titles: max 24 chars, descriptions: max 72 chars, max 10 rows per section
- Email subject: max 998 chars
- Voice language codes: ,
en-US,es-ES, etc. (auto-detected if omitted)pt-BR - Media messages auto-select WhatsApp channel
- 按钮标题:最多20个字符,最多3个按钮
- 列表项标题:最多24个字符,描述最多72个字符,每个章节最多10个列表项
- 邮件主题:最多998个字符
- 语音语言代码:、
en-US、es-ES等(若省略则自动检测)pt-BR - 媒体消息会自动选择WhatsApp渠道