Two-way

टेक्स्ट वापस आते हैं। तो उन्हें संभालें।

इसमें सेट अप करें:
Cursor

आपके provisioned नंबर पर कोई भी जो मैसेज भेजता है, वह एक HMAC-signed webhook के रूप में आता है। text पढ़ें, उसी नंबर से जवाब दें, और STOP और HELP को Bird पर छोड़ दें। जिस API से आप पहले से भेजते हैं, उसी पर conversational flows और auto-replies बनाएं।

send-otp.ts
200 · 0.4s
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

Hey Ada — your Bird sign-in code is 482917. It'll expire in 10 minutes. Don't share it with anyone.
482917
Delivered

Inbound बस एक और webhook है।

Two-way Bird SMS API का हिस्सा है। जब कोई आपके नंबर पर टेक्स्ट करता है, तो आपको उसी signed, replay-protected endpoint पर एक sms.received event मिलता है जो पहले से आपकी delivery receipts ले जाता है। कोई दूसरा integration नहीं और कोई polling नहीं — एक बार signature verify करें और type पर switch करें।

जो वापस आता है, उसे सुनें।

एक inbound मैसेज और एक opt-out events हैं, ठीक delivery receipt की तरह। एक signature verify करें, type पर switch करें, और हर एक को उसी handler में संभालें जो आपने पहले ही लिख लिया है।

app/api/webhooks/bird/route.ts
signed
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.receivedआपके नंबर पर एक inbound मैसेज आया — इसमें भेजने वाला, आपका नंबर, और text शामिल हैं।
  • sms.deliveredआपके द्वारा भेजा गया एक जवाब handset तक पहुँचा (carrier DLR)।
  • sms.opted_outभेजने वाले ने STOP टेक्स्ट किया — Bird ने उन्हें suppress कर दिया और आगे के sends ब्लॉक कर देता है।

एक signed inbound मैसेज, पूरे विस्तार में।

यहाँ देखें कि एक sms.received event wire पर कैसा दिखता है। from वह है जिसने आपको टेक्स्ट किया, to आपका provisioned नंबर है, और segments तथा encoding उसी तरह रिपोर्ट किए जाते हैं जैसे किसी send पर, इसलिए एक लंबा inbound जवाब कभी surprise नहीं होता।

sms.received
evt_
{
  "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 बनाएं।

reply.ts
200 · reply
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 के लिए एक two-way-capable नंबर चाहिए — long codes, short codes, और toll-free receive कर सकते हैं, alphanumeric sender ID नहीं कर सकते। उसी handset पर और समृद्ध बातचीत के लिए (typing indicators, read receipts, carousels), RCS बातचीत को upgrade करता है जहाँ डिवाइस support करता है।

docs में और गहराई से जाएं।

inbound events के लिए webhooks wire करें, जिन failures को आप संभालेंगे उनके लिए error reference पढ़ें, और keyword तथा consent नियमों के लिए abuse and compliance देखें।

Two-way SMS FAQ

एक inbound SMS मेरे app तक कैसे पहुँचता है?+
आपके provisioned नंबर पर भेजा गया हर मैसेज एक HMAC-signed sms.received webhook के रूप में आता है। आप एक signature verify करते हैं, from, to, और text पढ़ते हैं, और इसे अपने logic में route कर देते हैं — वही envelope जिसे आप पहले से delivery receipts के लिए handle करते हैं।
क्या मैं किसी inbound मैसेज का जवाब दे सकता हूँ?+
हाँ। उसी नंबर से भेजकर जवाब दें जिस पर मैसेज आया था। from को अपने नंबर पर और to को मूल भेजने वाले पर सेट करें, और पूरा thread एक ही नंबर पर बना रहता है, शुरू से अंत तक।
जब कोई STOP टेक्स्ट करता है तो क्या होता है?+
Bird भेजने वाले को आपकी suppression list में जोड़ देता है और sms.opted_out fire करता है, और उस नंबर पर आगे के sends को अपने आप ब्लॉक कर देता है। HELP एक help reply लौटाता है और START उन्हें वापस opt-in कर देता है — यह सब आपके code तक पहुँचने से पहले ही संभाला जाता है, इसलिए आप खुद keyword logic लिखे बिना compliant बने रहते हैं।
क्या two-way के लिए मुझे एक विशेष नंबर चाहिए?+
आपको एक two-way-capable नंबर चाहिए। Long codes, short codes, और toll-free नंबर inbound support करते हैं; alphanumeric sender ID केवल send-only होते हैं और replies नहीं पा सकते।

एक नंबर, एक API पर भेजें और पाएं।

Two-way inbound, Bird SMS API की एक क्षमता है: sending, numbers, compliance, routing, और analytics इसके साथ आते हैं, उस infrastructure पर जिसे हम एक दशक से चला रहे हैं।

एक चैनल से शुरुआत करें।
तैयार होने पर बाकी जोड़ें।

एक test API key तुरंत आपकी है। जब आप payment method जोड़ते हैं और sender verify करते हैं, तब production अनलॉक हो जाता है।

Claude Code, Cursor या Codex इस्तेमाल कर रहे हैं? एक setup prompt कॉपी करें और आपका agent आपके लिए Bird CLI और skills इंस्टॉल कर देगा। अपना चुनें:

Cursor