View Categories

SMS & WhatsApp setup

22 min read

Connect your SMS gateway and the Meta WhatsApp Cloud API.

Every feature in CartWin is free. There is no paid version and nothing is locked.

What it does. Sends the follow-up as a text message, through Twilio or through any gateway with an HTTP JSON API.

Why it matters. Text messages are read within minutes. For a cart abandoned an hour ago, one short SMS often outperforms a second email.

Details

Switching it on

  • Off until you switch it on (Settings → SMS → Send follow-ups by SMS). From then on an SMS channel appears under Templates, and CartWin normalises every phone number it captures to international format (see 4.1).
  • Only carts with a phone number receive SMS.
  • Text marketing needs the shopper’s consent in most countries. CartWin offers a separate consent checkbox for phone numbers (see 4.14); whether you need it is your decision, taken with your own legal advice.

Provider: Twilio

  • Three values: the Account SID, the Auth Token and the Sender — a Twilio phone number or a Messaging Service SID.
  • For each message CartWin calls Twilio’s Messaging API (https://api.twilio.com/2010-04-01/Accounts/<Account SID>/Messages.json) with the sender, the shopper’s number in international format (+15551234567) and the text.

Provider: other gateway with a JSON API

  • Any service that accepts an HTTP POST with a JSON body. Enter the Gateway URL and the Request body.
  • Put these placeholders in the body where the values belong: {to} (the shopper’s number), {from} (the sender) and {message} (the text). When the gateway wants the credentials inside the body rather than in a header, {sid} and {token} stand for the values entered under Account SID and Auth token.
  • Example: {"to": "{to}", "from": "{from}", "text": "{message}", "api_key": "{token}"}
  • The values are inserted JSON-escaped, so quotes and line breaks in a message cannot break the JSON.
  • Any answer with a 2xx status counts as sent. The gateway’s message id is taken from the first of these keys that is present: id, messageId, message_id, sid, uuid. Without any of them the message is still counted as sent.
  • A body that is not valid JSON once the placeholders are filled in is refused before anything leaves the store: “The SMS body template is not valid JSON once the placeholders are filled in.”
  • Gateways that want form fields, XML or a custom header are not served by this option. Ask the provider for a JSON API, or write your own sending code on the cartwin_send_sms filter (chapter 15).

The message

  • An SMS has no subject. The template text goes out as plain text: HTML tags are removed, <br> and the end of a paragraph, list item or table row become a line break, and {{cart.product.table}} becomes a plain list of item names.
  • CartWin does not split or shorten a long text; the provider does that, and bills each part. Keep an SMS short — one or two sentences plus the link.
  • Opt-out hint: the line from Settings → SMS (Reply STOP to opt out by default) is appended to every SMS whose text does not contain “STOP”. Leave the field empty for none. The hint is part of the message and counts towards its length.
  • Default country code: added in front of numbers typed without one (1 by default). Set it to the country most of your customers live in — the rules and examples are in 4.1. The same code is used for WhatsApp.

Replies: STOP

  • Customers answer a text with a text. Under Settings → SMS → STOP replies the store shows an address (the home page with ?cartwin_sms_event=1). Enter it in your Twilio console as the “A MESSAGE COMES IN” webhook of the number the messages are sent from.
  • A reply of STOP, UNSUBSCRIBE, CANCEL, END or QUIT unsubscribes that phone number in the store: the messages still queued for it are cancelled with the note “Customer unsubscribed.”, and a new cart with the same number is treated as unsubscribed as well.
  • The check is deliberately strict. Capitalisation and punctuation do not matter — “Stop!” counts — but the reply must consist of the word alone. “STOP sending me this” does not count and is only noted in the activity log.
  • An unsubscribe counts for every channel. A shopper who replies STOP gets no more emails or WhatsApp messages from the store either; a shopper who clicks the unsubscribe link in an email gets no more texts (see 4.14).
  • Only requests that carry a valid Twilio signature — made with your Auth Token — are honoured. Everything else is answered with “403 Forbidden”, so nobody can unsubscribe your customers from outside.
  • The address only works while the Provider is Twilio and the Auth Token is entered. With another gateway CartWin does not see replies; the gateway has to handle opt-outs on its side.
  • CartWin never answers a reply. It answers Twilio with an empty confirmation, and no message goes back to the shopper.

Sent, failed, and what is not tracked

  • Sent means Twilio or the gateway accepted the message. Whether the phone actually received or read it is not reported back to CartWin; there are no delivery or read receipts.
  • SMS have no open or click tracking.
  • When the provider rejects a message or cannot be reached, the SMS does not end as Failed at once: it goes back to the queue and is tried again — up to seven times, with growing pauses (3.4). The note names each attempt and the provider’s reason: Attempt 1 failed, retrying in 1 min: Twilio rejected the message: quota exceeded, or …: SMS gateway rejected the message: quota exceeded. When the reason is missing, the HTTP status stands there instead (“… rejected the message: HTTP 500”).
  • When the provider cannot be reached at all (time-out after 20 seconds, DNS, connection refused), the reason starts with “Twilio: ” or “SMS gateway: ” followed by WordPress’s reason.
  • After the last try the message is Failed. Queue again under Reports → Message Log gives it one more try (see 5.4).
  • Filter for staging sites: return false on cartwin_send_sms and no SMS goes out.

Where to find it. Settings → SMS. Then Templates (channel SMS).

What it does. Sends the follow-up as a WhatsApp message through the WhatsApp Business Cloud API from Meta.

Why it matters. WhatsApp has the highest open rates of the three channels in the markets where it is popular — and a cart restored from a WhatsApp message is one tap away.

Details

Switching it on

  • Off until you switch it on (Settings → WhatsApp → Send follow-ups by WhatsApp). From then on a WhatsApp channel appears under Templates, and CartWin normalises every phone number it captures to international format (see 4.1).
  • Three values from Meta:
  • API version — as shown in your Meta developer dashboard, for example v22.0. Left empty, v22.0 is used.
  • Phone number ID — from WhatsApp Manager → API setup. It is a long number that identifies your business phone line; it is not the phone number itself.
  • Access token — a permanent token from a system user of your Meta business portfolio. A 24-hour token from the API setup page expires; take a permanent one.
  • Until all three are in place no message goes out. Each one is tried again for about forty hours with “Add the Phone number ID from your WhatsApp business settings.” or “Add a permanent access token for your WhatsApp business account.” in its note, and ends as Failed (3.4).
  • The shopper’s number is taken from the cart in international format. The Default country code from Settings → SMS applies here too — the WhatsApp tab has no field of its own.
  • Only shoppers who opted in may be messaged. CartWin offers a consent checkbox for phone numbers (see 4.14).

How a CartWin template becomes a WhatsApp message

Meta does not let a business write to a customer out of the blue. Each CartWin template therefore picks a Message type:

  1. Approved WhatsApp template — the normal way. You first create the template in WhatsApp Manager (Meta reviews it, usually within a day), then enter in CartWin:
    – WhatsApp template name — exactly the name Meta shows. Meta only allows lower-case letters, digits and underscores; CartWin converts what you type accordingly (Cart Reminder 1 becomes cart_reminder_1), so copy the name from WhatsApp Manager to be safe.
    – Template language — the language code of the approved template, for example en_US or de. The field is filled with en_US when you leave it empty. It must be one of the languages the template is approved in.
    – Template values — one per line, in the order of the template’s {{1}}, {{2}} … placeholders. Merge tags are allowed in each line, for example:
    {{customer.firstname}}
    {{cart.total}}
    {{cart.item_count}}

    Each value is cut at 1,024 characters. Empty lines are left out, so an empty line in the middle moves every following value up by one — do not leave one there. Only placeholders in the body of the WhatsApp template are filled; a placeholder in the template’s header or footer is not.
    – Button link value — for a template with a dynamic website button. Create the button in WhatsApp Manager with a URL such as https://www.yoursite.com/?cartwin_restore={{1}} and enter {{cart.token}} here: the button then restores the cart. The value fills the first URL button of the template.
  2. Free text — sends the template text as an ordinary WhatsApp text message. CartWin removes the HTML and cuts the text at 4,096 characters. Meta only delivers such a message inside the 24-hour window after the customer last wrote to your business. A cart reminder usually falls outside that window, so Meta refuses it; the message is then tried again for about forty hours (3.4) and ends as Failed with Meta’s reason. Use this mode for tests — send a WhatsApp message to your business number first — and approved templates for real follow-ups.

What CartWin sends

  • One HTTPS request per message to https://graph.facebook.com/<API version>/<Phone number ID>/messages, carrying the access token as a Bearer token. Nothing else leaves the store.
  • When Meta accepts the message it returns a message id, which CartWin stores with the message record. It is the reference to look the message up in Meta’s logs with.

Sent, failed, and what is not tracked

  • Sent means Meta accepted the message. Whether the phone received or read it is not reported back to CartWin: CartWin does not read Meta’s delivery-status notifications, so there are no delivery or read receipts.
  • When Meta rejects a message, it goes back to the queue and is tried again — up to seven times, with growing pauses (3.4). The note names each attempt and Meta’s reason: Attempt 1 failed, retrying in 1 min: WhatsApp rejected the message: …. Common reasons: the template name or language does not match an approved template, the number is not on WhatsApp, the customer has blocked the business, a free-text message outside the 24-hour window, or the token has expired.
  • When Meta cannot be reached at all (time-out after 20 seconds, DNS), the reason starts with “WhatsApp: ” followed by WordPress’s reason.
  • Meta’s reason is written as Meta words it. For a malformed access token that text can contain the token itself — it then stands in the message note and in the activity log. Use a token exactly as Meta issued it, and keep the activity log private (chapter 14).
  • After the last try the message is Failed. Queue again under Reports → Message Log gives it one more try (see 5.4).
  • WhatsApp messages have no open or click tracking.
  • Filter for staging sites: return false on cartwin_send_whatsapp and no WhatsApp message goes out.

Opting out

  • WhatsApp has no automatic opt-out in CartWin. There is no “STOP” for WhatsApp here: CartWin does not receive WhatsApp replies, and when a customer blocks the business in their app, the store is not told.
  • Give customers a way out in the template itself, and honour it by hand: open the cart under Carts and click Unsubscribe. That cancels the messages queued for the cart, and new carts of the same customer are treated as unsubscribed.
  • An unsubscribe counts for every channel (see 4.14): a customer who replies STOP to an SMS, or clicks the link in an email, gets no WhatsApp messages either.

Where to find it. Settings → WhatsApp. Then Templates (channel WhatsApp).

Setting What it does Default Values / range
Send follow-ups by SMS “Off until you switch it on. Only carts with a phone number receive SMS, and text messaging needs the shopper’s consent in most countries.” Off On / Off
Provider Who sends the messages. Twilio Twilio · Other gateway with a JSON API
Account SID Twilio account. (empty) Text
Auth token Twilio token. (empty) Password field
Default country code “Added in front of phone numbers typed without a country code. 1 for the US and Canada.” 1 Digits
(heading: Twilio)
Sender “Your Twilio phone number or messaging service ID, in E.164 format.” (empty) Text
STOP replies A read-only URL. “Enter this URL as the “A MESSAGE COMES IN” webhook of your Twilio number. Shoppers who reply STOP are unsubscribed.” (site URL with cartwin_sms_event=1) —
(heading: Other gateway) — “A JSON request is sent to the URL. Use {to}, {from} and {message} where the values go.”
Gateway URL Where the JSON request is posted. (empty) URL
Request body The JSON body with the placeholders. (empty) Text — example: {"to": "{to}", "from": "{from}", "text": "{message}"}
Opt-out hint “Appended to every SMS that does not mention STOP yet. Leave empty for none.” Reply STOP to opt out Text

What the plugin checks before it sends: “Add the phone number or sender ID the messages are sent from.” for a missing Sender; with Twilio “Add your Twilio Account SID and Auth Token.”; with another gateway “Add the URL and the body template of your SMS gateway.” Until then no SMS goes out: each is tried again automatically for about forty hours with that text in its note, and ends as Failed. How the channel works: 4.4.

Setting What it does Default Values / range
Send follow-ups by WhatsApp “Off until you switch it on. Works with the WhatsApp Business Cloud API from Meta, and requires that shoppers opted in before you message them.” Off On / Off
API version “As shown in your Meta developer dashboard, for example v22.0.” v22.0 Text
Phone number ID “Found under WhatsApp Manager → API setup. It is not the phone number itself.” (empty) Text
Access token “Use a permanent token from a system user.” (empty) Password field

What the plugin checks before it sends: “Add the Phone number ID from your WhatsApp business settings.” and “Add a permanent access token for your WhatsApp business account.” Until then no WhatsApp message goes out: each is tried again automatically for about forty hours with that text in its note, and ends as Failed. The shopper’s numbers get the Default country code from the SMS section. How the channel works: 4.5.

What you need: an account with an SMS provider. CartWin supports Twilio directly and any gateway that takes a JSON request.

Twilio

  1. In your Twilio account, note the Account SID and the Auth Token, and the number or messaging service the messages come from.
  2. Under CartWin → Settings → SMS:
    – Provider: Twilio
    – Account SID, Auth token
    – Default country code: 1 for the US and Canada; change it for other countries. It is added in front of numbers typed without a country code.
    – Sender: your Twilio number or messaging service ID, in international format such as +15551234567.
    – Copy the URL shown under STOP replies.
  3. In Twilio, open the settings of that number and set the “A MESSAGE COMES IN” webhook to the URL you copied. A customer who replies STOP is then unsubscribed.
  4. Tick Send follow-ups by SMS and save. The admin shows an error until the required fields are filled.
  5. Consent: under Settings → Consent, consider ticking Ask for separate consent before recording phone numbers. Text marketing usually needs its own consent.
  6. Under Templates, the channel SMS is now available. Open Add Template → SMS, write a short message (merge tags work), choose Send after, and save.
  7. Click Test on the new template and send a test to your own phone.

Check the numbers before the first real message. From now on CartWin normalises the phone numbers it captures. Open Carts and look at the Phone column: the numbers must be complete international numbers, starting with + and the right country code. A number such as +17911123456 for a British customer means the Default country code is wrong.

What “Sent” means here. The message is marked Sent as soon as Twilio accepts it. Whether the phone received it is not reported back to CartWin. A rejection by Twilio shows as Failed with Twilio’s reason in the note.

Before you send to customers: many countries require you to register your business and your use case with the provider first. Ask your provider what applies to you.

Other gateway with a JSON API

  1. Under Settings → SMS, choose Provider: Other gateway with a JSON API.
  2. Enter the Gateway URL and the Request body with the placeholders:
    json
    {"to": "{to}", "from": "{from}", "text": "{message}"}

    {to}, {from} and {message} are replaced with the number, your sender and the text. {sid} and {token} give the values of the Account SID and Auth token fields — for gateways that expect the credentials in the body. The field names (to, from, text) are the ones your gateway expects: look them up in its API documentation and name them accordingly.
  3. Fill Sender with the value your gateway expects as the sender.
  4. Send a test (step 7 above). CartWin counts every answer from the gateway with status 2xx as Sent. If the test fails with “The SMS body template is not valid JSON once the placeholders are filled in.”, the request body is not valid JSON — check the quotation marks.
  5. STOP replies are handled only with Twilio. With another gateway, arrange the opt-out with the gateway, or leave the Opt-out hint in every message.

What you need: a Meta developer account, a WhatsApp Business Account, and a message template that Meta has approved.

  1. In the Meta developer dashboard, create an app and add the WhatsApp product. Note the API version, the Phone number ID (under WhatsApp Manager → API setup) and create a permanent access token with a system user.
  2. In WhatsApp Manager, create a template and wait for Meta’s approval. For a cart recovery message with a restore button, the template could look like this:
    – Name: cartwin_abandoned_cart
    – Language: English (US) → en_US
    – Body text: Hi {{1}}, you left {{2}} in your cart at Our Store. Tap below to complete your order.
    – Button: a Visit website button whose Website URL is https://your-store.com/?cartwin_restore={{1}}. {{1}} is the button’s variable; CartWin fills it with the cart’s code (step 4).
    WhatsApp requires the domain used in URL buttons to be verified in WhatsApp Manager. Check Meta’s current documentation for the exact steps and for what template types are allowed.
  3. Under CartWin → Settings → WhatsApp, enter the API version (for example v22.0), the Phone number ID and the Access token. Tick Send follow-ups by WhatsApp and save.
  4. Under Templates → Add Template → WhatsApp:
    – Message type: Approved WhatsApp template
    – WhatsApp template name: cartwin_abandoned_cart
    – Template language: en_US
    – Template values, one per line, in the order of the placeholders:
    {{customer.firstname}}
    {{cart.product.names}}

    – Button link value: {{cart.token}} — this fills the {{1}} of the URL button, so the button restores the cart.
    – Send after: for example 2 hours.
  5. Click Test and send a test to your own phone.

Testing with a test number. A new WhatsApp business setup starts with a test number. Meta only delivers its messages to the few numbers you register on the API setup page — put your own there. The 24-hour access token from that page expires: create a permanent one from a system user for the shop’s daily use.

What “Sent” means here. The message is marked Sent as soon as Meta accepts it. Whether the phone received or read it is not reported back to CartWin. When Meta refuses a message, it is tried again automatically and the note names each attempt and Meta’s reason — read it: it names the cause (unknown template, wrong language, number not on WhatsApp, expired token …). Only after the last try, about forty hours later, is the message marked Failed.

Rules that WhatsApp (Meta) sets

  • A business may only start a conversation with an approved template. Free text is delivered only within 24 hours after the customer messaged you.
  • The customer must have opted in. Use the consent checkbox under Settings → Consent.
  • Meta charges per conversation in most countries. Check Meta’s current pricing.
  • Opt-outs are in your hands. CartWin does not receive WhatsApp replies and is not told when a customer blocks you. Leave a way to object in the template — for example a line asking to reply or to write to you — and click Unsubscribe on that customer’s cart under Carts when the request arrives. An unsubscribe entered this way counts for every channel.

Are SMS and WhatsApp free?
The channels are part of CartWin and cost nothing extra. Your SMS or WhatsApp provider charges for the messages.

I do not see SMS or WhatsApp anywhere.
Both are switched off on a new installation. Turn a channel on under Settings → SMS or Settings → WhatsApp; it then appears under Templates.

Which SMS providers can I use?
Twilio, or any gateway that accepts an HTTP request with a JSON body. Put {to}, {from} and {message} where the gateway expects the number, the sender and the text (6.5). Gateways that need form fields or XML are not served by the generic option.

Do SMS and WhatsApp need separate settings?
Only the provider settings. Both use the same Default country code, and both go to the phone number of the cart.

How do I write the request body for my SMS gateway?
Take the example from your gateway’s documentation and replace the number, the sender and the text with {to}, {from} and {message}. If the gateway expects the key inside the body, {token} and {sid} stand for the two account fields. The result must be valid JSON.

My SMS fails with “not valid JSON”. What now?
The request body is not valid JSON once the placeholders are filled in. Check the quotation marks: each placeholder goes inside quotes, as in {"to": "{to}", "from": "{from}", "text": "{message}"}.

How do customers opt out of SMS?
With Twilio, by replying STOP, UNSUBSCRIBE, CANCEL, END or QUIT — once its webhook is set as described in 10.3. Every SMS carries the opt-out hint unless the text already mentions STOP. With another gateway the gateway must handle the opt-out.

Does a STOP reply also stop the emails?
Yes. An unsubscribe counts for every channel, whichever way it came about — a STOP reply, the link in an email or the Unsubscribe button.

Do SMS have open or click tracking?
No. “Sent” means the provider accepted the message. CartWin is not told whether the phone received or read it.

How long may an SMS be?
CartWin does not cut the text. Keep it short: providers split long texts into several parts and charge for each. The opt-out hint counts towards the length.

How are phone numbers written?
With SMS or WhatsApp on, in international format such as +15551234567. A + is kept, 00 becomes +, a leading trunk zero is dropped, and a number without a country code gets the Default country code in front. With both channels off, the number is stored as typed, without spaces.

Why is a phone number stored with the wrong country code?
The Default country code does not fit your customers. A British shopper who types 07911 123456 gets the code from the setting — with the default 1 that gives +17911123456. Set the code to your customers’ country (44 for the UK, 49 for Germany …) under Settings → SMS.

How do I switch on WhatsApp?
Enter the API version, Phone number ID and access token from Meta under Settings → WhatsApp, then tick Send follow-ups by WhatsApp (10.4).

My WhatsApp message is not delivered. Why?
Open the Message Log and read the note:
– Attempt failed, retrying in … min: WhatsApp rejected the message: … — Meta refused it, and CartWin is trying again. The usual causes: the template is not approved (or its name or language code does not match what you entered), the message type is Free text and more than 24 hours have passed since the customer messaged you, the number is not on WhatsApp, the customer has blocked you, or the token has expired. The note gives Meta’s own error text. Only after the eighth failed try is the message Failed.
– … WhatsApp: … — Meta could not be reached (time-out, connection); CartWin is trying again.
– Sent, but nothing arrives — Meta accepted the message, and what happens after that is not reported back to CartWin. Check the number, and the status of your WhatsApp number in WhatsApp Manager.

Can I send WhatsApp free text whenever I want?
No. Meta delivers free text only inside 24 hours after the customer messaged you. Outside that window an approved template is required — the normal case for a cart reminder.

Can I fill the placeholders in the header of my WhatsApp template?
No. CartWin fills the placeholders in the body of the template and the variable of the first URL button. Keep the header free of variables.

How do I give the WhatsApp message a button that restores the cart?
Create the template in WhatsApp Manager with a website button whose URL ends in {{1}}, for example https://www.yoursite.com/?cartwin_restore={{1}}, and enter {{cart.token}} as the Button link value in CartWin.

How do customers opt out of WhatsApp?
There is no automatic opt-out for WhatsApp in CartWin. Leave a way to object in the template, and click Unsubscribe on the customer’s cart under Carts when they ask.

May I message customers on SMS and WhatsApp?
Only customers who agreed to it. Switch on the consent checkboxes under Settings → Consent, and check the rules that apply in your country with your own legal advice.


Was this helpful?

Still stuck? Write to [email protected] with a screenshot and a description.

Download CartWin — it’s free

← Previous: Settings reference   |   Next: Webhooks & automation →