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 want to run a message on user action.
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.
using Screeb.Maui;
await Screeb.StartMessage("<message-id>");
You will find message id in Screeb platform.
Prevent multiple displays?
If current user already saw your message and you would rather not display it many times, please add the allowMultipleResponses argument:
using Screeb.Maui;
await Screeb.StartMessage("<message-id>", allowMultipleResponses: 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 ignoreMessageStatus argument and set it to false:
using Screeb.Maui;
await Screeb.StartMessage("<message-id>", ignoreMessageStatus: false);
Contextualize response
The StartMessage command accepts a list of hidden fields. Values passed as parameters will be listed alongside the responses, on the Screeb platform.
using Screeb.Maui;
await Screeb.StartMessage(
"<message-id>",
allowMultipleResponses: true,
hiddenFields: new Dictionary<string, object>
{
["color"] = "red",
["size"] = 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.
await Screeb.StartMessage("<message-id>", language: "en");