$textCampaign.cancelClient
This method allows canceling a message sent to a client during a text campaign depending on some condition set in the script.
Syntax
$textCampaign.cancelClient();
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:
- As part of your script, make the bot always ask and remember the client’s country or city of residence.
- Add a country check to the text campaign event handler.
- 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
# Here, we import the cities dictionary from the zb-common system project.
require: city/cityEn.sc
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: $client.city = $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: $client.city.country !== "BE"
script: $textCampaign.cancelClient();
go: /
else:
a: A 10% discount on all items if you register a bonus card! Are you interested?
# States for continuing the conversation…