长码是一种可发送和接收 SMS 的标准 10 位电话号码。它是中等用量下双向对话、OTP 和提醒的默认发送者。对于美国应用流量,它通过 A2P 10DLC 注册。
import { BirdClient } from "@messagebird/sdk";
const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });
const { data, error } = await bird.sms.send({
from: "Bird",
to: "+31612345678",
text: "Your order #4821 has shipped. Track it: bird.ly/t/4821x",
category: "transactional",
}).safe();
if (error) throw error;
console.log(data.id);
// → "sms_01m11jw130e7svjzv70kgqr38w"
何时长码是正确的选择。
长代码是 Bird SMS 号码界面上四种发送方类型之一,属于更广泛的 Bird SMS API 的一部分。它们是本地号码、支持双向通信且可快速开通——在消息量达到需要短代码的水平之前,长代码是大多数会话式和事务性通信的理想起点。
长码能带给你什么。
本地化呈现、双向流量、中等用量。
- 01
一个本地 10 位号码。
接收方看到的是来自他们自己国家/地区的区号,这读起来像是一个真实的发送者,而不是一次营销群发。
- 02
默认双向。
将号码的入站流量指向一个 webhook,回复将以签名事件的形式送达,这是构建会话流程的基础。
- 03
通过 A2P 10DLC 注册。
美国应用流量通过已注册的 10DLC 活动运行,这会赢得经审核的吞吐量和运营商的信任,而不是成为一个过滤风险。
- 04
注册一通过即刻生效。
立即购买号码;一旦其 10DLC 活动获批,它就开始承载已注册的流量。
购买一个并开始发送。
按国家和功能搜索并购买号码,使用与发送相同的客户端。入站流量通过订阅了 sms.received 的工作区 webhook 进行路由,而非按号码路由。相同的代码结构可配置任何发送者类型,只需更改 number_type。
// A US long code is a `local` number: the type names the numbering plan's
// own category, and "long code" is not one of them.
const { data: page, error: searchError } = await bird.numbers.available
.list({
country_code: "US",
number_type: "local",
capabilities: ["sms"],
})
.safe();
if (searchError) throw searchError;
const { data: order, error: orderError } = await bird.numbers.orders
.create({ number: page.data[0].number })
.safe();
if (orderError) throw orderError;
console.log(order.status, order.number_id); // → "completed" "nda_0ydh2yfw..."
注册是其中的一部分。
要向美国号码发送应用到个人流量,长码需通过一个已注册的 A2P 10DLC 活动运行。Bird 会从控制台提交品牌和活动,并通过 API 报告审批状态,让你确切知道何时可获得全速吞吐量。
付诸实践。
继续查阅此主题的文档、指南和示例。资源为英文。