Send a campaign

Send an approved template to your WhatsApp contacts and choose the agent that will handle replies. Check recipients, message and cost in the preview before confirming the send. Then read the campaign's results.

Before you start

You need:

  • An approved WhatsApp template.
  • A published agent to handle replies. Save its id in AGENT_ID.
  • The sending number's prefixedChannelId in CHANNEL_ID. The number must belong to the same WhatsApp account as the template.

To use the platform, see Campaigns.

  1. Create the campaign

    Give it a title and the template it sends. The title is unique in the workspace. (Create a campaign)

    import { Platic } from "platic-sdk";
    
    const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
    
    const campaign = await platic.campaigns.create({
      title: "Spring sale",
      category: "marketing",
      templateName: "spring_sale",
      language: "es_MX",
    });

    Save the campaign's id in CAMPAIGN_ID.

    category accepts marketing or utility. Use language to choose the template's language; the response shows the saved language. A missing template returns TEMPLATE_NOT_FOUND. A template that isn't approved returns TEMPLATE_NOT_APPROVED.

    If the template's button leads to your site, set where it goes with Update a campaign (ctaTargetUrl). Every recipient gets their own link, and the click and the purchase are measured.

  2. Build the audience

    Add contacts (clients in the API) by phone number, or all at once from a contact search, a tag or a list of ids. Contacts that don't exist in the workspace are created. (Add audience)

    const campaignId = campaign.id;
    
    await platic.campaigns.audience.add(campaignId, [
      { phoneNumber: "5215512345678", name: "Ana" },
      { phoneNumber: "5215587654321", name: "Luis" },
    ]);

    Send exactly one source: clients, searchId, tag or clientIds (up to 5,000). With dryRun: true it only says how many would join, without changing the audience. To see or remove people, use Get the audience, Remove from the audience and Clear the audience.

  3. Define a goal

    Define the result you want to measure, such as "Asked for a quote". The report counts campaign conversations that meet that criterion. (Goals)

    const goal = await platic.campaigns.goals.create(campaignId, {
      name: "Asked for a quote",
      criteria: "The customer asks about a price or asks for a quote.",
    });

    If the campaign already has a goal with that name, no other is created: the response is 200 with that goal and alreadyExisted: true. To change its criteria, update it with Goals.

  4. Preview the send

    Generate a preview first. Without sending messages, it shows the recipients, sending number, message with real data, cost and who will respond.

    Set who handles replies (replyHandling), the sending number (senderChannelId) and the template's values (variables). (Send a campaign)

    const decisions = {
      replyHandling: "agent",
      responderAgentId: process.env.AGENT_ID!,
      senderChannelId: process.env.CHANNEL_ID!,
      variables: ["client_firstname"],
    } as const;
    
    const preview = await platic.campaigns.previewSend(campaignId, decisions);
    console.log(preview.resumen, preview.avisos);

    Check resumen, mensaje, variables_sin_resolver and avisos. mensaje shows the variables filled with real contact data. The preview sends no messages and doesn't change the campaign.

    Blocked contacts and contacts who unsubscribed from marketing are excluded. Each date in scheduledDates repeats the full send to the same audience and incurs another charge.

  5. Confirm the send

    Send the confirmation from the preview with the same decisions. It is valid for 30 minutes and works for one send. (Send a campaign)

    if (preview.confirmation) {
      const sent = await platic.campaigns.send(campaignId, { ...decisions, confirmation: preview.confirmation });
      console.log(sent.runId);
    }

    Save the response's runId. It confirms that the send is queued; messages go out afterwards. Use the funnel in the next step to check progress without repeating the send call.

    If something changed since the preview (the audience, the template or the link's destination), nothing is sent and the response is 409 with what changed: ask for another preview. A confirmation that was already used also answers 409.

  6. Read the results

    The funnel counts distinct people at every step of each send (sent, delivered, read, clicks and purchases). The report covers a period: conversations, messages per day and how many met each goal. (Results)

    const funnel = await platic.campaigns.funnel(campaignId);
    for (const run of funnel.data.runs) console.log(run.runId, run.funnel, run.rates);
    
    const report = await platic.campaigns.report(campaignId, { startDate: "2026-11-01", endDate: "2026-11-30" });
    console.log(report.metrics, report.goals);

    Each metric requires its event: a click without a read receipt does not count as read. Amounts are in cents. If you omit dates, the report covers the current month in Mexico City time. Use Export recipients to download the recipients of a send as CSV.

Check it worked

Find your runId in the funnel and check that the sent count increases. When a contact replies, check the inbox to confirm that the conversation is assigned to the agent you chose.

Next steps