Skip to content

Templat

Daftar, periksa, sinkronkan, dan kirim templat WhatsApp dengan @wazapin/sdk.

Updated View as Markdown

Kirim templat

templateMessage() membangun struktur data bertingkat (nested wire shape) yang diharapkan oleh API — content.template.name, content.template.language.code, dan content.template.components.

import { templateMessage } from "@wazapin/sdk";

await wazapin.messages.send(
  templateMessage({
    channel_id: "wzp_ch_123",
    to: "6281234567890",
    name: "order_confirmation",
    language: "en_US",
    components: [
      {
        type: "body",
        parameters: [{ type: "text", text: "Order #123" }],
      },
    ],
  }),
);

Body JSON yang setara:

{
  "channel_id": "wzp_ch_123",
  "to": "6281234567890",
  "type": "template",
  "content": {
    "template": {
      "name": "order_confirmation",
      "language": { "code": "en_US" },
      "components": [
        {
          "type": "body",
          "parameters": [{ "type": "text", "text": "Order #123" }]
        }
      ]
    }
  }
}

Daftar templat

const { data: page } = await wazapin.templates.list({ limit: 50 });

for (const template of page.items) {
  console.log(template.id);
}

Dapatkan satu templat

const template = await wazapin.templates.get("tpl_123");

Sinkronkan templat

await wazapin.templates.sync();
Navigation

Type to search…

↑↓ navigate↵ selectEsc close