Skip to main content


This method allows canceling a message sent to a client during a text campaign depending on some condition set in the script.



How to use

Let’s assume you want to send a text campaign targeted at residents of a specific country, such as Belgium.

One option is to aggregate clients from Belgium into a list of clients based on some set of features you know about, then send a text campaign only to clients from this list. However, this is not always possible.

Instead, you can develop the script in a way to include the necessary business logic:

  1. As part of your script, make the bot always ask and remember the client’s country or city of residence.
  2. Add a country check to the text campaign event handler.
  3. If the client is not from the target country, call $textCampaign.cancelClient and abort the campaign script.
How canceled messages are displayed in the interface
Campaign card. The campaign progress bar is along the bottom-hand border and is divided into two segments, green and yellow, corresponding to messages that have been sent to clients and canceled respectively.
# Here, we import the cities dictionary from the zb-common system project.
require: city/
module = sys.zb-common

theme: /

# The script branch where the bot learns the client’s city.
state: Start || modal = true
q!: $regex</start>
a: Hi! Could you please tell me which city you live in?

state: GetCity
q: * $City *
script: $ = $parseTree._City;
a: Thank you! Now I’m at your service.
go: /

state: CatchAll || noContext = true
event: noMatch
a: Sorry, but I won’t be able to function properly without knowing where you live.

# The state for handling the event triggered by the campaign launch.
state: Promo
event!: promoEvent
if: $ !== "BE"
script: $textCampaign.cancelClient();
go: /
a: A 10% discount on all items if you register a bonus card! Are you interested?

# States for continuing the conversation…