# Confirm اور Cancel بٹنوں کے ساتھ WhatsApp پر آرڈر کی تصدیق

> Confirm اور Cancel quick replies والا utility آرڈر ٹیمپلیٹ بھیجیں، ٹیپ کو context.id سے ملائیں، آرڈر ایک بار اپ ڈیٹ کریں، اور جواب نہ آنے اور free text کو سنبھالیں۔

Published 2026-11-25. Z-API Omni team.

دو quick reply بٹنوں والا ایک custom UTILITY ٹیمپلیٹ بنائیں، آرڈر بنتے ہی اسے بھیجیں، اور ہر بٹن کو `confirm:1042` جیسا payload دیں۔ ٹیپ، `type: "button"` کے ساتھ `messages` webhook کے طور پر آتا ہے۔ اسے `context.id` سے آرڈر کے ساتھ ملائیں، جو وہی message ID ہے جو آپ نے send کے وقت محفوظ کی تھی۔ پھر conditional update سے آرڈر کو `pending_confirmation` سے نکالیں، تاکہ دوسرا ٹیپ کچھ نہ بدلے۔

یہ صفحہ کسی بھی shop backend کے لیے عمومی چکر ہے۔ Shopify والا ورژن [Shopify order webhooks سے WhatsApp](/academy/ur/articles/shopify-order-webhook-whatsapp-notifications/) میں ہے، اور WooCommerce والا [WooCommerce آرڈر status، WhatsApp پر](/academy/ur/articles/woocommerce-order-status-whatsapp-webhooks/) میں۔ یہی بٹن والا چکر [cash-on-delivery کی تصدیق](/academy/ur/articles/whatsapp-cash-on-delivery-order-verification/)، [return اور refund اپ ڈیٹس](/academy/ur/articles/whatsapp-return-refund-status-updates/) اور [Supabase table سے آرڈر کی اطلاعات](/academy/ur/articles/supabase-database-webhook-whatsapp-notification/) بھی چلاتا ہے۔

## یہ ٹیمپلیٹ utility کے طور پر کیوں پاس ہوتا ہے

Meta کا categorization صفحہ کہتا ہے کہ utility ٹیمپلیٹ «غیر تشہیری ہو، اس میں کوئی تشہیری یا قائل کرنے والا ارادہ نہ ہو»۔ یہ «صارف سے متعلق یا اس کی درخواست پر» ہو، یا «صارف کے لیے ضروری یا اہم» ہو، اور «عام طور پر صارف کے کسی عمل یا درخواست سے trigger ہوتا ہے» ([template categorization، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/template-categorization))۔ کسٹمر کا ابھی دیا ہوا آرڈر تینوں شرطیں پوری کرتا ہے۔

Meta کا order management مقصد یوں ہے: «کسٹمر کے ساتھ کسی آرڈر یا transaction کی تصدیق، اپ ڈیٹ یا منسوخی»۔ اسی صفحے کے مطابق ایسا پیغام «مصنوعات کی تشہیر، سفارش، upsell یا cross-sell» نہ کرے۔ یہ «promo والی آرڈر اپ ڈیٹ» کو مارکیٹنگ میں شمار کرتا ہے۔ discount codes، مصنوعات کی تجاویز اور review کی درخواستیں اس ٹیمپلیٹ سے باہر رکھیں۔ جب Meta کسی ٹیمپلیٹ کی کیٹیگری بدلے تو کیا ہوتا ہے، یہ [ٹیمپلیٹ کیٹیگریز کی وضاحت](/academy/ur/articles/whatsapp-template-categories-marketing-utility-authentication/) میں ہے۔

### Template Library کا ٹیمپلیٹ کیوں نہیں

Template Library میں `ORDER_CONFIRMATION` use case filter ہے، اور library ٹیمپلیٹس کا `UTILITY` ہونا لازمی ہے، جن کا «مواد مقرر ہے اور اس میں ترمیم نہیں ہو سکتی» ([Template Library، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/template-library))۔ صفحہ اس type کی کوئی body نہیں دکھاتا۔ یہ بھی نہیں بتاتا کہ library ٹیمپلیٹ میں Confirm اور Cancel کے quick replies ہو سکتے ہیں۔ اس لیے ایک custom UTILITY ٹیمپلیٹ لکھیں، اور `ORDER_CONFIRMATION` کو اس سے ملتی جلتی library type سمجھیں۔ library کی تفصیل [WhatsApp Template Library](/academy/ur/articles/whatsapp-template-library-prebuilt-templates/) میں ہے۔

## ٹیمپلیٹ کو TTL کے ساتھ بنائیں

Meta ہر ٹیمپلیٹ میں 10 تک quick reply بٹنوں کی اجازت دیتا ہے، ہر ایک کا label زیادہ سے زیادہ 25 حروف ([template components، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/components))۔ یہاں دو کافی ہیں۔ body میں named parameters ہیں، تاکہ آرڈر نمبر اور کل رقم آپس میں جگہ نہ بدل سکیں۔

ٹیمپلیٹ بناتے وقت time-to-live سیٹ کریں۔ Meta کا TTL صفحہ utility کا default «30 دن» بتاتا ہے اور `message_send_ttl_seconds` سے اسے «30 سیکنڈ سے 12 گھنٹے» تک سیٹ کرنے دیتا ہے ([time-to-live، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/templates/time-to-live))۔ صفحہ ہر send پر الگ override کا ذکر نہیں کرتا۔ «سسٹم ان پیغامات کو drop کر دیتا ہے جو default یا customized TTL کے اندر ڈیلیور نہ ہو سکیں۔» TTL کے بغیر، تصدیق کی درخواست کسی ایسے فون تک پہنچ سکتی ہے جو کئی دن بند رہا، جبکہ package پہلے ہی روانہ ہو چکا ہو۔

نیچے 6 گھنٹے کی value اس مثال کے لیے ہماری اپنی پسند ہے۔ Meta کوئی value تجویز نہیں کرتا۔

```bash
curl -X POST "https://graph.facebook.com/v26.0/$WABA_ID/message_templates" \
  -H "Authorization: Bearer $WA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "order_confirm_v1",
  "category": "UTILITY",
  "language": "en_US",
  "parameter_format": "NAMED",
  "message_send_ttl_seconds": 21600,
  "components": [
    {
      "type": "BODY",
      "text": "Hi {{customer_name}}, we received order {{order_number}} for {{order_total}}. Please confirm it or cancel it below.",
      "example": {
        "body_text_named_params": [
          { "param_name": "customer_name", "example": "Ana" },
          { "param_name": "order_number", "example": "1042" },
          { "param_name": "order_total", "example": "$84.90" }
        ]
      }
    },
    {
      "type": "BUTTONS",
      "buttons": [
        { "type": "QUICK_REPLY", "text": "Confirm order" },
        { "type": "QUICK_REPLY", "text": "Cancel order" }
      ]
    }
  ]
}'
```

اسے صرف ان کسٹمرز کو بھیجیں جنہوں نے opt-in کیا ہو۔ Meta کا تقاضا ہے کہ opt-in میں بزنس کا نام ہو اور یہ بات ہو کہ وہ شخص اس کے پیغامات وصول کرنے کے لیے opt-in کر رہا ہے۔ opt-in «عمومی ہو سکتا ہے، خاص طور پر WhatsApp کے لیے ہونا ضروری نہیں» ([getting opt-in، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/getting-opt-in))۔ checkout پر ایک checkbox جس پر لکھا ہو «مجھے SHOP_NAME سے آرڈر کی اپ ڈیٹس WhatsApp پر بھیجیں» کافی ہے۔ جمع کرنے کے طریقے [WhatsApp opt-in کیسے جمع کریں](/academy/ur/articles/whatsapp-opt-in-how-to-collect-consent/) میں ہیں۔

## ہر بٹن کے payload کے ساتھ بھیجیں

بھیجتے وقت ہر quick reply کو ایک `button` component ملتا ہے، `sub_type: "quick_reply"`، اس کا `index` اور ایک `payload` parameter کے ساتھ۔ payload میں action اور آرڈر ID رکھیں: `confirm:1042` اور `cancel:1042`۔ response سے `messages[0].id` کو آرڈر کے ساتھ محفوظ کریں۔ یہی wamid آپ کی join key ہے۔

Meta کا موجودہ components صفحہ send کے وقت والے `payload` parameter کو دستاویز نہیں کرتا۔ یہ syntax، Meta کے پرانے On-Premises interactive templates صفحے پر ہے، جس پر بند ہونے کا نشان لگا ہے ([interactive message templates، رسائی 2026-11-25](https://developers.facebook.com/docs/whatsapp/api/messages/message-templates/interactive-message-templates))۔ وہ صفحہ کہتا ہے کہ callback آپ کا payload واپس لاتا ہے، اور خبردار کرتا ہے کہ صارفین ٹیپ کرنے کی بجائے ٹائپ بھی کر سکتے ہیں۔ اسی لیے نیچے والی سروس کبھی صرف payload پر انحصار نہیں کرتی۔

## جواب کا webhook اور اسے کیسے ملائیں

Meta کے button reference کے مطابق ٹیپ، `entry[].changes[].value.messages[]` میں اس شکل میں آتا ہے ([button webhook، رسائی 2026-11-25](https://developers.facebook.com/documentation/business-messaging/whatsapp/webhooks/reference/messages/button)):

```json
{
  "context": {
    "from": "<BUSINESS_DISPLAY_PHONE_NUMBER>",
    "id": "<CONTEXTUAL_WHATSAPP_MESSAGE_ID>"
  },
  "from": "<WHATSAPP_USER_PHONE_NUMBER>",
  "from_user_id": "<BSUID>",
  "id": "<WHATSAPP_MESSAGE_ID>",
  "timestamp": "<WEBHOOK_TRIGGER_TIMESTAMP>",
  "type": "button",
  "button": {
    "payload": "<BUTTON_LABEL_TEXT>",
    "text": "<BUTTON_LABEL_TEXT>"
  }
}
```

Meta، `context.id` کی تعریف یوں کرتا ہے: «اس پیغام کی WhatsApp message ID جس میں وہ بٹن تھا جو WhatsApp صارف نے ٹیپ کیا»۔ پہلے اسی پر match کریں۔ `from` field شرطیہ ہے: جب صارف کا username ہو اور کوئی فون نمبر دستیاب نہ ہو تو Meta اسے چھوڑ دیتا ہے۔ ایسے کسٹمر کے لیے فون سے lookup ناکام ہو جاتا ہے، جبکہ `context.id` پھر بھی آرڈر ڈھونڈ لیتا ہے۔

پھر `button.payload` پڑھیں۔ reference اسے بٹن کا label بتاتا ہے، اور اس کی مثال میں payload اور text دونوں "Unsubscribe" پر سیٹ ہیں۔ اگر payload، `confirm:<id>` یا `cancel:<id>` کے طور پر parse نہ ہو تو `button.text` پر جائیں۔ جواب آرڈر پر محفوظ فون نمبر کو دیں، webhook سے لیے گئے نمبر کو کبھی نہیں۔

ٹیپ 24 گھنٹے کی کسٹمر سروس ونڈو کھول دیتا ہے، اس لیے «آپ کا آرڈر منسوخ ہو گیا» والا جواب free-form text ہو سکتا ہے۔ اس ونڈو کے اندر پیغامات پر Meta کی billing، 2026-10-01 کو بدل گئی، جیسا کہ [اکتوبر 2026 سے سروس پیغامات کی فیس](/academy/ur/articles/meta-whatsapp-service-message-charges-october-2026/) میں بیان ہے۔

## آرڈر کی حالتیں

ہر آرڈر ان حالتوں سے گزرتا ہے:

| حالت | کب داخل ہوتا ہے | shop میں write-back |
| --- | --- | --- |
| `pending_confirmation` | ٹیمپلیٹ بھیجا جاتا ہے | کوئی نہیں |
| `confirmed` | pending کے دوران Confirm ٹیپ ہوا | status `confirmed` کا PATCH |
| `cancelled` | pending اور unfulfilled کے دوران Cancel ٹیپ ہوا | status `cancelled` کا PATCH؛ آپ کا backend stock واپس کرتا ہے |
| `expired_no_reply` | TTL سے پہلے delivery نہیں ہوئی، یا آپ کی آخری حد تک کوئی جواب نہیں آیا | کوئی نہیں۔ فیصلہ کوئی شخص کرتا ہے |

handler کو دو جگہ idempotent بنائیں۔ پہلی، inbound پیغامات کو `messages[].id` پر dedupe کریں، کیونکہ Meta ناکام deliveries کو retry کرتا ہے اور وہی ٹیپ دو بار آ سکتا ہے ([جب آپ کا webhook endpoint بند ہو تو کیا ہوتا ہے](/academy/ur/articles/whatsapp-webhook-retries-endpoint-down/))۔ دوسری، حالت کی تبدیلی کو شرطیہ بنائیں: `UPDATE orders SET status = 'confirmed' WHERE id = $1 AND status = 'pending_confirmation'`۔ اگر کوئی row نہ بدلے تو آرڈر پہلے ہی اس حالت سے نکل چکا ہے۔ Cancel کے بعد آنے والا Confirm، فیصلہ الٹنے کی بجائے ایک شائستہ جواب بن جاتا ہے۔

## مکمل سروس

یہ Node 18+ فائل `npm install express` کے بعد چلتی ہے۔ یہ آپ کے backend سے آرڈر events لیتی ہے، ٹیمپلیٹ بھیجتی ہے، Meta کا `X-Hub-Signature-256` verify کرتی ہے، ٹیپس ملاتی ہے اور واپس لکھتی ہے۔ یہ فرض کرتی ہے کہ آپ کا backend، JSON `status` کے ساتھ `PATCH SHOP_API_URL/orders/<id>` قبول کرتا ہے۔ in-memory maps کی جگہ tables لگائیں، اور conditional update برقرار رکھیں۔

```js
// order-confirm-service.js. Node 18+. npm install express
const crypto = require("crypto");
const express = require("express");

const {
  WA_TOKEN, PHONE_NUMBER_ID, APP_SECRET, VERIFY_TOKEN,
  SHOP_API_URL, SHOP_API_TOKEN, EVENT_TOKEN, PORT = "3000",
} = process.env;

const GRAPH_URL = `https://graph.facebook.com/v26.0/${PHONE_NUMBER_ID}/messages`;
const TTL_MS = 21600 * 1000;           // same value as message_send_ttl_seconds
const REPLY_DEADLINE_MS = 24 * 3600 * 1000; // your choice

const orders = new Map();   // orderId -> order
const byWamid = new Map();  // wamid of the template -> orderId
const seen = new Set();     // inbound message ids already handled

function transition(order, from, to) {
  if (order.status !== from) return false; // UPDATE ... WHERE status = from
  order.status = to;
  order.updatedAt = Date.now();
  return true;
}

async function graphSend(body) {
  const res = await fetch(GRAPH_URL, {
    method: "POST",
    headers: { Authorization: `Bearer ${WA_TOKEN}`, "Content-Type": "application/json" },
    body: JSON.stringify({ messaging_product: "whatsapp", ...body }),
  });
  const json = await res.json();
  if (!res.ok) throw new Error(`Graph ${res.status}: ${JSON.stringify(json.error ?? json)}`);
  return json;
}

const sendText = (to, text) => graphSend({ to, type: "text", text: { body: text } });

async function sendConfirmation(order) {
  const quickReply = (index, payload) => ({
    type: "button", sub_type: "quick_reply", index,
    parameters: [{ type: "payload", payload }],
  });
  const json = await graphSend({
    to: order.phone,
    type: "template",
    template: {
      name: "order_confirm_v1",
      language: { code: "en_US" },
      components: [
        {
          type: "body",
          parameters: [
            { type: "text", parameter_name: "customer_name", text: order.customerName },
            { type: "text", parameter_name: "order_number", text: order.number },
            { type: "text", parameter_name: "order_total", text: order.total },
          ],
        },
        quickReply(0, `confirm:${order.id}`),
        quickReply(1, `cancel:${order.id}`),
      ],
    },
  });
  return json.messages[0].id;
}

async function patchOrder(orderId, status) {
  const res = await fetch(`${SHOP_API_URL}/orders/${encodeURIComponent(orderId)}`, {
    method: "PATCH",
    headers: { Authorization: `Bearer ${SHOP_API_TOKEN}`, "Content-Type": "application/json" },
    body: JSON.stringify({ status }),
  });
  if (!res.ok) throw new Error(`shop PATCH ${res.status}`);
}

function handOff(order, reason, detail) {
  // Replace with a ticket, a Slack message or an inbox assignment.
  console.log("needs_person", { orderId: order?.id ?? null, reason, detail });
}

function readAction(msg) {
  const [verb, id] = String(msg.button?.payload ?? "").split(":");
  if ((verb === "confirm" || verb === "cancel") && id) return { verb, id };
  const label = String(msg.button?.text ?? "").trim().toLowerCase();
  if (label === "confirm order") return { verb: "confirm" };
  if (label === "cancel order") return { verb: "cancel" };
  return null;
}

function findPendingByPhone(phone) {
  if (!phone) return null;
  for (const o of orders.values()) {
    if (o.phone === phone && o.status === "pending_confirmation") return o;
  }
  return null;
}

async function handleMessage(msg) {
  if (seen.has(msg.id)) return;
  seen.add(msg.id);

  const linkedId = byWamid.get(msg.context?.id);
  const order = linkedId ? orders.get(linkedId) : findPendingByPhone(msg.from);
  if (!order) return handOff(null, "unmatched_message", { id: msg.id, type: msg.type });
  if (msg.type !== "button") return handOff(order, "free_text", msg.text?.body ?? msg.type);

  const action = readAction(msg);
  if (!action || (action.id && action.id !== order.id)) {
    return handOff(order, "unreadable_button", msg.button);
  }
  if (order.status === "expired_no_reply") {
    handOff(order, "late_reply", action.verb);
    return sendText(order.phone, `Thanks. A person from our team will follow up on order ${order.number} here.`);
  }

  if (action.verb === "confirm") {
    if (!transition(order, "pending_confirmation", "confirmed")) {
      return sendText(order.phone, `Order ${order.number} is already ${order.status.replace(/_/g, " ")}. Reply here if that looks wrong.`);
    }
    try {
      await patchOrder(order.id, "confirmed");
    } catch (err) {
      order.status = "pending_confirmation";
      handOff(order, "write_back_failed", err.message);
      return sendText(order.phone, `We got your reply for order ${order.number}. A person from our team will confirm it here.`);
    }
    return sendText(order.phone, `Thanks. Order ${order.number} is confirmed.`);
  }

  if (order.fulfilled) {
    handOff(order, "cancel_after_fulfillment", null);
    return sendText(order.phone, `Order ${order.number} is already being fulfilled. A person from our team will reply here.`);
  }
  if (!transition(order, "pending_confirmation", "cancelled")) {
    return sendText(order.phone, `Order ${order.number} is already ${order.status.replace(/_/g, " ")}. Reply here if that looks wrong.`);
  }
  try {
    await patchOrder(order.id, "cancelled");
  } catch (err) {
    order.status = "pending_confirmation";
    return handOff(order, "write_back_failed", err.message);
  }
  return sendText(order.phone, `Order ${order.number} is cancelled. Reply here if you have a question about it.`);
}

function handleStatus(status) {
  const order = orders.get(byWamid.get(status.id));
  if (!order) return;
  if (status.status === "delivered") {
    order.deliveredAt = Date.now();
    if (order.status === "expired_no_reply") console.log("late_delivery", { orderId: order.id });
  }
  if (status.status === "failed") {
    transition(order, "pending_confirmation", "expired_no_reply");
    handOff(order, "template_failed", status.errors);
  }
}

const app = express();

// Your shop backend posts { type: "order.created" | "order.fulfilled", order }.
app.post("/events", express.json(), async (req, res) => {
  if (req.get("authorization") !== `Bearer ${EVENT_TOKEN}`) return res.sendStatus(401);
  const { type, order } = req.body ?? {};
  if (type === "order.fulfilled" && orders.has(String(order?.id))) {
    orders.get(String(order.id)).fulfilled = true;
    return res.sendStatus(200);
  }
  if (type !== "order.created" || !order?.id) return res.sendStatus(400);
  const id = String(order.id);
  if (orders.has(id)) return res.sendStatus(200); // repeated event
  if (!order.whatsappOptIn) return res.sendStatus(202); // no opt-in, no message

  const record = {
    id, number: String(order.number), total: String(order.total),
    customerName: order.customerName, phone: order.phone, // digits with country code
    status: "pending_confirmation", fulfilled: false, sentAt: Date.now(), deliveredAt: null,
  };
  orders.set(id, record);
  try {
    const wamid = await sendConfirmation(record);
    byWamid.set(wamid, id);
    record.wamid = wamid;
    res.sendStatus(200);
  } catch (err) {
    record.status = "expired_no_reply";
    handOff(record, "send_failed", err.message);
    res.sendStatus(502);
  }
});

app.get("/webhook", (req, res) => {
  const ok = req.query["hub.mode"] === "subscribe" && req.query["hub.verify_token"] === VERIFY_TOKEN;
  return ok ? res.send(req.query["hub.challenge"]) : res.sendStatus(403);
});

app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const expected = "sha256=" + crypto.createHmac("sha256", APP_SECRET).update(req.body).digest("hex");
  const given = Buffer.from(req.get("x-hub-signature-256") ?? "");
  if (given.length !== expected.length || !crypto.timingSafeEqual(given, Buffer.from(expected))) {
    return res.sendStatus(401);
  }
  res.sendStatus(200);

  const body = JSON.parse(req.body.toString("utf8"));
  for (const entry of body.entry ?? []) {
    for (const change of entry.changes ?? []) {
      if (change.field !== "messages") continue;
      for (const s of change.value?.statuses ?? []) handleStatus(s);
      for (const m of change.value?.messages ?? []) {
        handleMessage(m).catch((err) => handOff(null, "handler_error", err.message));
      }
    }
  }
});

// No silent cancels: expired orders go to a person and stay open in the shop.
setInterval(() => {
  const now = Date.now();
  for (const o of orders.values()) {
    if (o.status !== "pending_confirmation") continue;
    if (!o.deliveredAt && now - o.sentAt > TTL_MS) {
      transition(o, "pending_confirmation", "expired_no_reply");
      handOff(o, "not_delivered_within_ttl", null);
    } else if (o.deliveredAt && now - o.deliveredAt > REPLY_DEADLINE_MS) {
      transition(o, "pending_confirmation", "expired_no_reply");
      handOff(o, "no_reply", null);
    }
  }
}, 60 * 1000);

app.listen(Number(PORT), () => console.log(`listening on ${PORT}`));
```

آرڈر پر فون نمبر country code کے ساتھ صرف ہندسوں میں ہونا چاہیے، اسی شکل میں جس میں Meta اسے `from` میں رکھتا ہے۔ فون سے متبادل lookup صرف تب چلتا ہے جب کسی پیغام کا `context.id` کسی محفوظ ٹیمپلیٹ سے نہ ملے، اور ٹائپ کیے گئے text میں عموماً یہی ہوتا ہے۔

## جب کوئی جواب نہ دے

کسٹمر کے ٹیپ نہ کرنے پر کبھی خاموشی سے آرڈر منسوخ نہ کریں۔ پیشگی ادا شدہ آرڈر کے لیے معقول default یہ ہے کہ اسے رکھیں اور روانہ کر دیں۔ cash on delivery کے لیے کوئی شخص فون کر سکتا ہے یا قواعد کے اندر ایک follow-up بھیج سکتا ہے، پھر فیصلہ کرے۔

TTL کی وجہ سے drop ہونے والے پیغام کے لیے Meta کوئی error code نہیں بتاتا۔ سروس «TTL ختم ہونے سے پہلے کوئی `delivered` status نہیں» کو drop مانتی ہے۔ `delivered` status پھر بھی دیر سے آ سکتا ہے، اس لیے آرڈر expire ہونے کے بعد بھی اسے log کریں۔ `failed` status سیدھا کسی شخص کے پاس جاتا ہے۔

## ٹائپ کیے گئے جوابات اور دیر سے منسوخی

کسٹمرز ٹیپ کرنے کی بجائے "no"، "wrong address" یا کوئی سوال ٹائپ کر دیتے ہیں۔ بٹن کے علاوہ ہر پیغام کسی شخص کے پاس بھیجیں۔ "no" کو منسوخی نہ سمجھیں، جب تک آپ پہلے تصدیق کا قدم نہ بھیجیں، جیسے reply بٹن والا پیغام جو پوچھے «آرڈر 1042 منسوخ کریں؟»۔ ونڈو کے اندر بھیجی جانے والی یہ پیغام کی type [interactive reply بٹن](/academy/ur/articles/whatsapp-interactive-buttons-list-messages-limits/) میں ہے۔

Cancel صرف تب قبول کریں جب آرڈر unfulfilled ہو۔ اس کے بعد اپنے support یا returns کے راستے سے جواب دیں۔ shop کے اپنے قواعد بھی لاگو رہتے ہیں۔ Shopify کا `orderCancel` ایسے آرڈرز رد کر دیتا ہے جن کی باقی fulfillments وہ منسوخ نہیں کر سکتا، جبکہ WooCommerce کوئی وقت کی حد نافذ نہیں کرتا، اس لیے یہ کام آپ کے code کو کرنا ہو گا۔

Webhooks [بے ترتیب](/academy/ur/articles/whatsapp-webhooks-out-of-order-message-sequencing/) بھی آ سکتے ہیں۔ Cancel کا ٹیپ اسی ٹیمپلیٹ کے `delivered` status سے پہلے بھی پہنچ سکتا ہے۔ سروس کو اس سے فرق نہیں پڑتا، کیونکہ حالت کی تبدیلی آرڈر کے status پر منحصر ہے، events کی ترتیب پر نہیں۔

## Z-API Omni کہاں کام آتا ہے

Omni یہی ٹیمپلیٹ `POST https://api.omni.z-api.io/v1/channels/{channelId}/messages` سے، `Authorization: Bearer <Secret Key>` کے ساتھ بھیجتا ہے۔ اس کا custom-model صفحہ quick reply کے payload component کو دستاویز کرتا ہے۔ منقطع channel، `subCode: CHANNEL_DISCONNECTED` کے ساتھ `422` واپس کرتا ہے، اور پیغام نہیں بھیجا جاتا۔ ٹیمپلیٹ بناتے وقت `message_send_ttl_seconds` قبول ہوتا ہے۔ docs ابھی بٹن ٹیپ کی inbound شکل نہیں دکھاتے۔

<!-- TODO:test Omni snippet: send with quick-reply payloads; whether body params need parameter_name on a NAMED template; inbound JSON of the tap (where payload and text land, and whether message_id_reply links it to the template's messageId) -->
```json
{
  "recipient": { "identifier": "5511999999999" },
  "content": {
    "type": "TEMPLATE",
    "attachments": [{
      "template": {
        "name": "order_confirm_v1",
        "language": { "policy": "deterministic", "code": "en_US" },
        "components": [
          { "type": "body", "parameters": [
            { "type": "text", "text": "Ana" },
            { "type": "text", "text": "1042" },
            { "type": "text", "text": "$84.90" }
          ] },
          { "type": "button", "sub_type": "quick_reply", "index": 0, "parameters": [{ "type": "payload", "payload": "confirm:1042" }] },
          { "type": "button", "sub_type": "quick_reply", "index": 1, "parameters": [{ "type": "payload", "payload": "cancel:1042" }] }
        ]
      }
    }]
  }
}
```

ایک subscription میں WhatsApp، Messenger، Instagram اور Telegram شامل ہیں، 1 سے 10 نمبروں کے لیے US$29 فی نمبر ماہانہ پر، اور webhooks بغیر حد کے شامل ہیں۔ QR connection پر نہ ٹیمپلیٹس ہیں نہ فی پیغام لاگت؛ وہاں `INTERACTIVE_BUTTON` پیغام میں تین تک بٹن ہوتے ہیں۔ Meta کی آفیشل API پر Meta کی فیس آگے منتقل ہوتی ہے۔

[دستاویزات دیکھیں](https://developer.omni.z-api.io/en)

*Z-API Omni ٹیم*
