आपके provisioned नंबर पर कोई भी जो मैसेज भेजता है, वह एक HMAC-signed webhook के रूप में आता है। text पढ़ें, उसी नंबर से जवाब दें, और STOP और HELP को Bird पर छोड़ दें। जिस API से आप पहले से भेजते हैं, उसी पर conversational flows और auto-replies बनाएं।
import { BirdClient } from "@messagebird/sdk";
const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });
const code = generateOtp();
const { data, error } = await bird.sms.send({
from: "Bird",
to: "+15005550006",
text: `Your Bird verification code is ${code}. Reply STOP to opt out.`,
category: "authentication",
}).safe();
if (error) throw error;
console.log(data.id);
// → "sms_4kT01Lq2m..."
Today at 2:14 PM
Inbound बस एक और webhook है।
Two-way is part of the Bird SMS API. When someone texts your number, you get an sms.received event on the same signed, replay-protected endpoint that already carries your delivery receipts. There's no second integration and no polling: verify the signature once and switch on the type.
जो वापस आता है, उसे सुनें।
एक inbound मैसेज और एक opt-out events हैं, ठीक delivery receipt की तरह। एक signature verify करें, type पर switch करें, और हर एक को उसी handler में संभालें जो आपने पहले ही लिख लिया है।
import { bird } from "@/lib/bird";
export async function POST(req: Request) {
const event = bird.webhooks.unwrap(
await req.text(),
Object.fromEntries(req.headers),
);
switch (event.type) {
case "sms.received":
await handleInbound(event.data.from, event.data.text);
break;
case "sms.opted_out":
await removeFromCampaigns(event.data.from);
break;
}
return new Response(null, { status: 204 });
}payload हर Bird channel पर वही envelope है: एक evt_ id, एक HMAC signature, और एक replay-protected timestamp।
sms.receivedAn inbound message landed on your number: carries the sender, your number, and the text.sms.deliveredआपके द्वारा भेजा गया एक जवाब handset तक पहुँचा (carrier DLR)।sms.opted_outThe sender texted STOP: Bird suppressed them and blocks future sends.
एक signed inbound मैसेज, पूरे विस्तार में।
यहाँ देखें कि एक sms.received event wire पर कैसा दिखता है। from वह है जिसने आपको टेक्स्ट किया, to आपका provisioned नंबर है, और segments तथा encoding उसी तरह रिपोर्ट किए जाते हैं जैसे किसी send पर, इसलिए एक लंबा inbound जवाब कभी surprise नहीं होता।
{
"id": "evt_7nQ9xLp2aR...",
"type": "sms.received",
"created_at": "2026-06-26T14:03:11Z",
"data": {
"id": "sms_5hV02Mr3n...",
"from": "+15005550006",
"to": "+14155550172",
"text": "YES book me in for Thursday",
"encoding": "GSM-7",
"segments": 1
}
}उसी नंबर से जवाब दें।
एक जवाब वही send है जिसमें from और to आपस में बदल दिए गए हों। from को अपने नंबर पर और to को मूल भेजने वाले पर सेट करें, और बातचीत एक ही नंबर पर बनी रहती है, ताकि प्राप्तकर्ता को हर बार नए sender के बजाय एक thread दिखे। इसके ऊपर auto-replies, confirmations, या पूरा conversational flow बनाएं।
async function handleInbound(from: string, text: string) {
if (/^yes\b/i.test(text)) {
const { error } = await bird.sms.send({
from: "+14155550172", // your two-way number
to: from, // reply to the sender
text: "Booked. See you Thursday at 10am.",
category: "transactional",
}).safe();
if (error) throw error;
}
}STOP, HELP, और START आपके लिए संभाले जाते हैं।
Bird आपके handler तक पहुँचने से पहले ही reserved keywords को पहचान लेता है: STOP भेजने वाले को आपकी suppression list में जोड़ता है और sms.opted_out fire करता है, HELP एक automatic help reply लौटाता है, और START उन्हें वापस opt-in कर देता है। किसी suppressed नंबर पर आगे के sends अपने आप ब्लॉक हो जाते हैं। आप YES, BOOK, या अपने flow के लिए ज़रूरी किसी भी चीज़ के लिए अपने खुद के keywords रख सकते हैं। पूरे keyword और opt-out नियम opt-out handling में मौजूद हैं।
दो चीज़ें जो आप आगे चाहेंगे।
Inbound needs a two-way-capable number: long codes, short codes, and toll-free can receive, alphanumeric sender IDs can't. For richer back-and-forth on the same handset (typing indicators, read receipts, carousels), RCS upgrades the conversation where the device supports it.
docs में और गहराई से जाएं।
inbound events के लिए webhooks wire करें, जिन failures को आप संभालेंगे उनके लिए error reference पढ़ें, और keyword तथा consent नियमों के लिए abuse and compliance देखें।
Two-way SMS FAQ
एक inbound SMS मेरे app तक कैसे पहुँचता है?
क्या मैं किसी inbound मैसेज का जवाब दे सकता हूँ?
जब कोई STOP टेक्स्ट करता है तो क्या होता है?
क्या two-way के लिए मुझे एक विशेष नंबर चाहिए?
बाकी का SMS platform
एक API, keys का एक सेट। बाकी क्षमताओं को explore करें।
एक नंबर, एक API पर भेजें और पाएं।
Two-way inbound, Bird SMS API की एक क्षमता है: sending, numbers, compliance, routing, और analytics इसके साथ आते हैं, उस infrastructure पर जिसे हम एक दशक से चला रहे हैं।