Start message programmatically
How to start a message programmatically?
In most cases, you should let the Screeb targeting engine start the message. But sometimes, you may need more control on message trigger time.
You can find the MESSAGE_ID in the Manual section of the message editor.
You can also find it in the message editor URL, after the /messages/ part.
$screeb("message.start", "<MESSAGE_ID>");
Prevent multiple displays?
If current user already replied to your message and you would rather not display it many times, please add the allow_multiple_responses argument:
$screeb("message.start", "<MESSAGE_ID>", { allow_multiple_responses: false });
Respect message status?
By default, using manual message start will ignore the message status. If you want to respect the message status, you can add the ignore_message_status argument and set it to false:
$screeb("message.start", "<MESSAGE_ID>", { ignore_message_status: false });
Contextualize response
The message.start command accepts an object of hidden fields. Values passed as parameters will be listed alongside the responses, on the Screeb platform.
$screeb("message.start", "<MESSAGE_ID>", {
hidden_fields: { color: "green", article_id: 42 },
});
Force language
If you want to force the message language, you can pass the language parameter:
Here is the order of priority for the language:
message.start param > init param > user property > browser language.
$screeb("message.start", "<MESSAGE_ID>", { language: "en" });
How to close a message?
You can close the currently running message with the message.close command. Optionally, you can pass a message id to close a specific message.
// Close all running messages
$screeb("message.close");
// Close a specific message
$screeb("message.close", "<MESSAGE_ID>");