WhatsApp Campaigns
v0.1.11Send WhatsApp campaigns: templates, audiences, surveys, inbox replies, delivery webhooks.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
capabilities
Describe the gateway: tool catalog, the scopes this key holds, and pricing posture. Call first to plan what you may do.
search_templates
Search the published template MARKETPLACE (templates from every org, to clone). Returns normalized listings (id, name, rating, cloneCount, categoryKeys). For your OWN templates use list_templates.
| Parameter | Type | Description |
|---|---|---|
category | string | MarketplaceCategory key, e.g. EVENTS. |
channel | string | |
page | number | |
pageSize | number | |
q | string | Free-text search over name + description. |
sort | string |
list_templates
List YOUR org's own message templates (not the marketplace), newest first, with channel and provider approval status (APPROVED / PENDING / REJECTED / NOT_SUBMITTED) and any rejection reason. Filter by text, channel or approvalStatus. Archived templates only with includeArchived.
| Parameter | Type | Description |
|---|---|---|
approvalStatus | string | Only templates in this provider approval state. |
channel | string | |
includeArchived | boolean | |
page | number | |
pageSize | number | |
q | string | Free-text search over name + description. |
get_template
Fetch one template by id (a published marketplace listing or one your org owns).
| Parameter | Type | Description |
|---|---|---|
id * | string |
render_template
Validate a template and return the rendered RCS payload + variable-bound SMS/MMS fallback, without sending. Use to inspect before cloning/sending.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
variables | object | Merge fields ({{key}} -> value) to bind into the preview. |
create_template
Create a template draft in your org. Compose a TemplateContent (text/card/carousel) with a REQUIRED non-empty smsFallback; the shared RCS validator gates it. Submit it (submit_template) and await provider approval before send_message for rich RCS; an unsubmitted template delivers as SMS fallback.
| Parameter | Type | Description |
|---|---|---|
content * | object | TemplateContent. Must include a non-empty smsFallback. One of text/card/carousel is the primary body. |
name * | string | |
category | string | |
channel | string | |
description | string | |
tags | array |
update_template
Partially update a template your org owns: name, description, category, tags, knowledgeDoc, and content (re-validated by the shared RCS validator — a non-empty smsFallback is still required). Only the fields you pass change. Editing the CONTENT of an already-approved template invalidates that approval: submit_template it again and await approval, or it delivers as SMS fallback until then. Use get_template first to edit incrementally rather than overwriting blind.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
category | string | |
channel | string | Move the template to another channel. Requires the matching add-on brand; omit to leave it where it is. |
content | object | Full replacement TemplateContent (not a deep merge). Must include a non-empty smsFallback. |
description | string | |
knowledgeDoc | string | |
name | string | |
tags | array |
duplicate_template
Duplicate a template your org OWNS into a fresh private draft (e.g. to iterate a variant without touching the original). The copy keeps the content, channel, category, tags and knowledge base, but starts unsubmitted — it has no provider approval of its own until you submit_template it. For copying someone else's PUBLISHED marketplace listing, use clone_template instead.
| Parameter | Type | Description |
|---|---|---|
id * | string |
delete_template
Delete a template your org owns. IRREVERSIBLE, and it also removes the template from the provider (Twilio), so an approved template loses its approval and can no longer be sent. Broadcasts that already went out are unaffected. Prefer this only for drafts and abandoned iterations; ask the user before deleting anything they have submitted or sent.
| Parameter | Type | Description |
|---|---|---|
id * | string |
clone_template
Clone a published marketplace template into your org as a fresh private draft. Returns the new template. To deliver rich RCS rather than SMS fallback, submit_template it and await provider approval before send_message.
| Parameter | Type | Description |
|---|---|---|
id * | string |
submit_template
Submit an org-owned template to the provider (Twilio) for approval. Returns the contentSid + approval status.
| Parameter | Type | Description |
|---|---|---|
id * | string |
send_message
Send an org-owned template to a list of E.164 phone numbers (RCS-first with mandatory SMS/MMS fallback). Pass the template's blueprintId or id. The template sends as rich RCS only after submit_template + provider approval; until then it delivers as SMS fallback — the returned funnel's `fellBackToSms` count signals how many recipients got SMS instead of RCS. Bills your org. Returns the send funnel.
| Parameter | Type | Description |
|---|---|---|
blueprintId * | string | |
to * | array | |
name | string | |
variables | object |
search_surveys
List/search the surveys your org owns. Returns each survey with its recipients + responses counts.
| Parameter | Type | Description |
|---|---|---|
page | number | |
pageSize | number | |
q | string | Free-text search over the name. |
status | string |
get_survey
Fetch one survey your org owns by id (its full definition).
| Parameter | Type | Description |
|---|---|---|
id * | string |
render_survey
Preview a survey the way a respondent sees it: the text body + RCS chip titles for each question. Side-effect-free.
| Parameter | Type | Description |
|---|---|---|
id * | string |
create_survey
Create a survey draft in your org. Provide a SurveyDefinition (intro? + questions[] of type rating/single_select/text/comment); the shared validator gates it. PICTURES: every question should carry an `imageUrl`, and the definition should carry `headerImageUrl` (start picture) and `outroImageUrl` (finish picture). If the user provided no pictures, WEB-SEARCH for suitable, relevant images first and pass their https URLs — the server automatically re-hosts every image onto the platform GCS bucket, so external URLs are safe to pass and never hotlinked.
| Parameter | Type | Description |
|---|---|---|
definition * | object | SurveyDefinition: { intro?, outro?, questions: [{ questionId, prompt, type, options?, minRating?, maxRating?, required? }] }. |
name * | string | |
channel | string | Channel to act on (RCS or WHATSAPP). Defaults to your org's own brand channel; any other channel requires the matching add-on brand. |
description | string | |
endDate | string | |
isPreferencesSurvey | boolean | |
languageCode | array | |
startDate | string | ISO date; schedules the survey. |
timezone | string |
clone_survey
Duplicate an org-owned survey into a fresh DRAFT (e.g. to iterate a variant). Returns the new survey.
| Parameter | Type | Description |
|---|---|---|
id * | string |
delete_survey
Delete a survey your org owns. IRREVERSIBLE: its responses and sessions are deleted with it, so any results you have not already read are lost. Ask the user before deleting a survey that has been sent or has responses — read get_results first if in doubt.
| Parameter | Type | Description |
|---|---|---|
id * | string |
submit_survey
Submit a survey for provider approval: on RCS its button-question templates, on WhatsApp its single Flow template. Returns the survey with the resulting approval state.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
channel | string | Channel to act on (RCS or WHATSAPP). Defaults to your org's own brand channel; any other channel requires the matching add-on brand. |
send_survey
Send a survey to explicit E.164 numbers (the CRM-triggered single-customer send) and/or saved audiences. Flips the survey ACTIVE. Bills your org. Returns { recipients, sent }. Every send is a campaign (WhatsApp sends the approved Flow, RCS the question-by-question run) and also returns campaignId and queued: sending: true means the rest is still going out in the background (do not send again), and halted / heldByAllowance / groundStopped say why a send stopped short.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
audienceIds | array | |
channel | string | Channel to act on (RCS or WHATSAPP). Defaults to your org's own brand channel; any other channel requires the matching add-on brand. |
to | array | E.164 destinations, e.g. ["+15551234567"]. |
update_survey
Partially update a survey: name, description, definition (re-validated; editing a submitted WhatsApp survey requires resubmission), startDate/endDate, and audienceIds — setting audienceIds on a future-dated survey schedules the send to fire automatically at startDate. PICTURES: as with create_survey, keep every question's `imageUrl` plus `headerImageUrl`/`outroImageUrl` populated — web-search for images when none were provided; the server re-hosts all image URLs onto GCS.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
audienceIds | array | |
channel | string | Channel to act on (RCS or WHATSAPP). Defaults to your org's own brand channel; any other channel requires the matching add-on brand. |
definition | object | |
description | string | |
endDate | string | |
name | string | |
startDate | string | |
status | string |
list_survey_sends
A survey's outbound send log (live + test sends), newest first, with per-message delivery status — including failed/stubbed attempts and the reason they did not deliver.
| Parameter | Type | Description |
|---|---|---|
id * | string |
send_survey_test
Send a one-off TEST of the survey to a single E.164 number (does not change status or audiences). Check list_survey_sends afterwards for the delivery outcome.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
number * | string | E.164, e.g. +15551234567. |
channel | string | Channel to act on (RCS or WHATSAPP). Defaults to your org's own brand channel; any other channel requires the matching add-on brand. |
get_results
Read a survey’s aggregated results: per-question option counts / rating averages / text samples + completion totals (multi-part questions aggregate per part; free-text answers are auto-translated to English). Pass campaignId (returned by send_survey, or a SURVEY campaign’s id from list_campaigns) for that one send’s results; without it the totals span the whole survey, test sends and every campaign included.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
campaignId | string | Only the responses answered from this survey campaign (24-hex id). A campaign that is not this survey’s is a 404. |
upload_media
Store one picture on the platform GCS bucket and get its stable https URL — the only kind of URL survey/template media should use. Pass EITHER the image inline (base64 + mime) OR an https sourceUrl the server fetches and re-hosts (use this for web-searched pictures).
| Parameter | Type | Description |
|---|---|---|
base64 | string | Raw base64 or data: URL of the image bytes. |
filename | string | |
mime | string | Image MIME type (required with base64), e.g. image/png. |
sourceUrl | string | https image URL to fetch and re-host onto GCS. |
get_knowledge
Read a template's knowledge base: the grounding document text plus whether answering is enabled. Use before set_knowledge to edit a doc incrementally instead of overwriting it blind.
| Parameter | Type | Description |
|---|---|---|
id * | string |
set_knowledge
Set/replace a template's knowledge base: the grounding document AI answers are generated from when recipients reply. Include operating instructions in the doc itself — e.g. "Any question not answered by this document must be answered exactly: …". Setting a doc re-enables answering.
| Parameter | Type | Description |
|---|---|---|
doc * | string | The knowledge document (markdown or plain text). |
id * | string |
delete_knowledge
Delete a template's knowledge base document.
| Parameter | Type | Description |
|---|---|---|
id * | string |
enable_knowledge
Enable knowledge answering on a template (the doc is used again).
| Parameter | Type | Description |
|---|---|---|
id * | string |
disable_knowledge
Disable knowledge answering on a template WITHOUT deleting the doc (pause).
| Parameter | Type | Description |
|---|---|---|
id * | string |
get_usage
Read your org’s month-to-date metered message usage.
search_audiences
List/search the audiences (saved contact lists) your org owns. Returns each audience with its name, source, and contactCount.
| Parameter | Type | Description |
|---|---|---|
page | number | |
pageSize | number | |
q | string | Free-text search over the name. |
get_audience
Fetch one audience your org owns by id.
| Parameter | Type | Description |
|---|---|---|
id * | string |
list_audience_contacts
Paginated list of an audience's contacts. Use `q` to find someone in a large imported batch instead of paging through it — it matches on the server, over the whole audience, so it keeps working on lists too big to page.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
page | number | |
pageSize | number | |
q | string | Free-text over number, names and email. A number matches however it is written — "(206) 300-0001" finds "+12063000001". |
create_audience
Create a saved audience (contact list) in your org, optionally seeded with contacts (e.g. leads parsed from a CSV). Every contact needs a reachable E.164-ish `number` — a contact with no valid number fails the whole create with a 400 (fix the row rather than silently dropping it). Use `attributes` for any extra CSV columns you want available as {{key}} merge fields later.
| Parameter | Type | Description |
|---|---|---|
name * | string | |
contacts | array | |
description | string | |
source | string | Free-text provenance, e.g. "Jaipur wedding planners leads.csv". |
import_contacts
Append contacts to an existing audience (e.g. more leads from a later CSV batch). Same reachability rule as create_audience: every contact needs a valid `number` or the whole import 400s.
| Parameter | Type | Description |
|---|---|---|
contacts * | array | |
id * | string |
update_audience
Rename an audience or change its description (null or an empty string clears it). Only the fields you pass change; its contacts are untouched.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
description | string | null | |
name | string |
remove_audience_contacts
Take people off an audience, by each row's `id` from list_audience_contacts (its `contactId` works too). This is not an opt-out: the person, their message history and their other audiences are untouched, and ids not in the audience are ignored. Returns the audience with its new contactCount and how many were removed.
| Parameter | Type | Description |
|---|---|---|
contactIds * | array | |
id * | string |
delete_audience
Delete an audience and all of its contacts (org-scoped, irreversible).
| Parameter | Type | Description |
|---|---|---|
id * | string |
list_conversations
List the org's conversation threads (one per phone number), newest activity first. Archived threads are hidden. Filter by free text, unread, unassigned, a specific assignee, or the campaign a thread was messaged in.
| Parameter | Type | Description |
|---|---|---|
assignedTo | string | Only threads owned by this Clerk user id. |
broadcastId | string | Only threads this campaign was sent to. |
page | number | |
pageSize | number | |
search | string | Match the number or the resolved display name. |
unassigned | boolean | Only threads nobody owns. |
unread | boolean | Only threads with unanswered arrivals (unreadCount > 0). Org-wide, not per-viewer: a key is not a person and has no read state. |
get_conversation
Read one thread in a single call: its meta, the most recent messages (ascending), the contact summary (marketing status, tags, audiences) and whether the WhatsApp 24h service window is open. Internal team notes are deliberately NOT included.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
limit | number | How many of the most recent messages to include. |
reply
Reply into a thread — free text (with an optional image) or an approved template. Reaches a real phone and bills your org. Every gate an operator hits applies unchanged: an opted-out number is refused (409), the org allowance is enforced, WhatsApp free text needs the 24h window open (an approved template otherwise), and an RCS send always carries its SMS fallback. When the thread has an outbound language set, free text is translated into it first, exactly as the human composer does.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
kind * | string | |
blueprintId | string | kind=template: the org template to send. |
mediaUrl | string | kind=text: a public https image URL to attach. |
text | string | kind=text: the body. May be empty when mediaUrl carries the message. |
variables | object | kind=template: values for the template's {{variables}}. |
assign_conversation
Give a thread an owner, or release it back to the pool with `userId: null`. The assignee is a bare Clerk user id and is NOT validated against the org roster — a stale id degrades to "assigned to someone who left", visibly, rather than to an outage in a one-field write.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
userId * | string | null | Clerk user id to hand the thread to; null releases it. |
list_webhooks
The org's registered outbound webhook endpoints. The signing secret is redacted — it is shown only once, by create_webhook.
create_webhook
Register an HTTPS endpoint to receive signed platform events. The response carries the signing `secret` EXACTLY ONCE — store it now; every later read redacts it and there is no way to retrieve it again. Each delivery is signed `X-RCS-Signature: t=<unix>,v1=<hex HMAC-SHA256 of "<t>.<rawBody>">`.
| Parameter | Type | Description |
|---|---|---|
events * | array | Event types to subscribe to. |
url * | string | HTTPS endpoint to POST events to. |
description | string |
update_webhook
Update an endpoint's url, subscribed events, description, or active flag. Only the fields you pass change. The signing secret is never returned or rotated here.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
active | boolean | |
description | string | null | |
events | array | |
url | string |
delete_webhook
Remove a webhook endpoint. Its delivery history is deleted with it; anything still queued for it stops.
| Parameter | Type | Description |
|---|---|---|
id * | string |
test_webhook
Fire a synthetic signed event at one endpoint to verify the receiver. Returns the delivery id and whether it was accepted.
| Parameter | Type | Description |
|---|---|---|
id * | string |
list_contacts
Search the org's contact records (one person per number, across every audience). Returns consent, opt-out, number verdict, marketing status, merge fields and tags.
| Parameter | Type | Description |
|---|---|---|
audienceId | string | Only people who are members of this audience. |
page | number | |
pageSize | number | |
q | string | Free-text over number, names and email. |
status | string | Marketing status: SUBSCRIBED (consent, not opted out), UNSUBSCRIBED (opted out — sticky), UNDELIVERABLE (number known unreachable), UNKNOWN (no consent on record). |
tag | string |
get_contact
Fetch one contact by its public contact id, with the audiences they belong to.
| Parameter | Type | Description |
|---|---|---|
id * | string |
update_contact
Correct a contact's names, email, merge fields (`attributes`, a whole-map replace) or tags. Consent and opt-out are deliberately NOT reachable from here — recording or clearing them is a compliance-sensitive action that stays with a human operator.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
attributes | object | null | Whole-map replace of the {{merge field}} values. |
email | string | null | |
firstName | string | null | |
lastName | string | null | |
tags | array |
list_campaigns
List YOUR org's campaigns (broadcasts), newest first, with status (DRAFT / SCHEDULED / SENDING / SENT / FAILED / CANCELLED), channel, the template sent, audience count, schedule (scheduledAt in the campaign's own timezone) and the delivery funnel (total, delivered, read, failed, fellBackToSms, clicked). Archived campaigns are hidden. Read-only: creating, scheduling or sending a campaign happens in the web app.
| Parameter | Type | Description |
|---|---|---|
channel | string | |
page | number | |
pageSize | number | |
q | string | Free-text search over the campaign name. |
status | string |
get_campaign_analytics
Campaign analytics, the same figures as the web app's Analytics page: totals and rates (delivered, read, clicked, failed, fell back to SMS) over the last N days (default 30, max 365), a daily series (UTC days; hourly for a 1-day window), failure classes by provider error code, after-delivery outcomes (replied, opportunity, not interested) and a per-campaign table. Pass broadcastId (a list_campaigns id) to narrow every figure to one campaign over its own lifetime. Aggregate only — no phone numbers or message text.
| Parameter | Type | Description |
|---|---|---|
broadcastId | string | One campaign (its list_campaigns id). |
channel | string | Only this channel. Omit for every campaign. |
days | number |
list_campaign_groups
List YOUR org's campaign groups — named sets of campaigns filed together (an event, a launch, a quarter) — most recently changed first, each with its member campaign ids, campaign count and combined delivery funnel (every member's funnel added together, from cached figures). Pass broadcastId (a list_campaigns id) for only the groups that campaign is in.
| Parameter | Type | Description |
|---|---|---|
broadcastId | string | Only the groups this campaign (a list_campaigns id) is in. |
get_campaign_group
One campaign group: its member campaigns (status, channel, schedule and each funnel, refreshed when stale) and their combined funnel. Campaigns deleted since they were filed are left out.
| Parameter | Type | Description |
|---|---|---|
id * | string |
create_campaign_group
Create a campaign group, optionally filing campaigns (list_campaigns ids) in it at once. Names are unique per org, ignoring case and spacing. A group never changes who a campaign reaches or when it sends; a campaign may be in several groups.
| Parameter | Type | Description |
|---|---|---|
name * | string | |
broadcastIds | array | Campaigns (list_campaigns ids) to start the group with. |
description | string |
update_campaign_group
Rename a campaign group or change its description (null clears it). Only the fields you pass change; use add_campaigns_to_group / remove_campaigns_from_group to change its campaigns.
| Parameter | Type | Description |
|---|---|---|
id * | string | |
description | string | null | |
name | string |
delete_campaign_group
Delete a campaign group. Only the group goes: its campaigns, their recipients and their results are untouched.
| Parameter | Type | Description |
|---|---|---|
id * | string |
add_campaigns_to_group
File campaigns (list_campaigns ids) in a campaign group. Idempotent: a campaign already in the group stays where it is. Returns the group with its campaigns.
| Parameter | Type | Description |
|---|---|---|
broadcastIds * | array | |
id * | string |
remove_campaigns_from_group
Take campaigns out of a campaign group. The campaigns themselves are untouched; ids not in the group are ignored. Returns the group with its campaigns.
| Parameter | Type | Description |
|---|---|---|
broadcastIds * | array | |
id * | string |