Promo Code Detection
This tool allows for the detection and highlighting of promo codes sent in a chat and also activates the widget that will allow users to activate these promo codes through a target link.
Configure recognition patterns for promo codes and URLs to automatically identify and process promotional content. If activated, all promo codes that users send in chat will be highlighted. Users will be able to click activate, and their promo code will be automatically added to the specified link.
When you activate the tool on the admin panel (Widgets > Promo code), you need to choose how the system identifies codes: when users send only separate codes or when the codes are included in a message.
Then, you need to add the promo code prefix. The prefix has to be up to 10 characters, e.g., ABCDE. Near, you need to add an example of a promo code to help the system identify them.
Optionally, you can define a URL pattern. Example: https://www.example.com/path/ + GGWP4A1V5C. Detected promo codes will include an Activate button that opens the specified URL for code activation.
Opening the activation link
You can choose how the Activate button opens the activation link. On the admin panel (Widgets > Promo code), select one of the options under "Open the link in":
- New window (default). The link opens in a new browser tab or window.
- Current window. The link opens in the same window where the chat is running, replacing the chat page. Use this option when the chat runs in its own WebView and the activation page should be shown in its place.
- Send post message. The chat does not open the link itself. Instead, it sends an event with the link to your application, and the application decides how to open it (for example, in an in-app browser or a native screen). Use this option when links cannot be opened from inside the container where the chat is embedded.
Post message format
With the "Send post message" option selected, the widget sends the following object when a user taps Activate:
{
"type": "link",
"body": {
"action": "open",
"data": {
"link": "https://www.example.com/path/GGWP4A1V5C"
}
}
}
The message is delivered through the channel that matches your integration:
- Android WebView: the
WatchersChannelJavaScript interface receives the object as a JSON string viaWatchersChannel.postMessage. - iOS WKWebView: the
WatchersChannelscript message handler (window.webkit.messageHandlers.WatchersChannel) receives the object as a JSON string. - Web page with an iframe: the parent window receives the object through the standard
window.postMessageAPI. Subscribe to it withwindow.addEventListener('message', ...)on the page that embeds the chat.