Scenario Fields
Scenario fields are temporary fields with information that are pre-created in the scenario wizard, and are passed to the API-request to the start of the scenario.
Scenario fields are bound to a specific scenario, and the values passed into them are bound to the specific contact with which they are passed. The fields exist and are used from the moment the contact enters the initial “API” block until the contact completes the scenario. When the scenario is completed, the values in the scenario fields are cleared.
Scenario fields are used to store temporary information about a contact that is needed only when the contact goes through a particular scenario. Most often, they are used to store event data (date, time, name, link), information about an event, an order, and any other data that does not need to be stored for a long time (such as the contact's city or date of birth).
Creating scenario fields
To use scenario fields, create them beforehand in the scenario editing window.
Specify the name of the field and its type. Please note that the possibilities of working with this field will depend on the specified type: mathematical and comparison operations are available only for numeric fields, and using the field in the “Pause” block is available only for date and date-time types.
After creating the field, you can pass it with the required value in the /v1/event/start/{scenarioId}/{blockId}/ method (scenarioFields parameter).
Using scenario fields in blocks
You can use scenario fields in blocks:
- distribution - contacts can be directed to different scenario branches via the “Distribution” block depending on the values in their scenario fields;
- data modification - the values of scenario fields for contacts can be set, overwritten or cleared during the scenario flow;
- API request - it is allowed to substitute scenario fields in:
- URL,
- body,
- headers,
- parameters;
- pause - it is possible to pause the contact, in which it will wait for the date in the scenario field or the specified time before/after the date value in the scenario field.
For example, you can create a chain with reminders about an event by using “Pause before date in scenario field” blocks and sending messages to different channels:
- Pass a contact with the start date of the event
- Pause “wait 3 days until the date in the scenario field”.
- After the pause put a block to send an email reminding about the event
- Pause again “wait 1 day before the date in the scenario field”
- Sending a WhatsApp message with a reminder
- Pause “wait 1 hour before the date in the scenario field”
- SMS with a reminder about the start of the event
This will be a universal conversation that will send notifications to all the contacts caught in it, regardless of what event they have signed up for and when exactly that event will happen. You can display all the necessary information about the event that is unique for each contact in the messages using the dynamic content methods.
Outputting scenario field values to messages
Use of scenario fields is available for Email, WhatsApp and SMS in the message body
You can output the value of the scenario fields in the messages of this scenario using the dynamic content method {{user_guide:scenario:scenario_fields:scenariofield.name}}where Name is the name of the field specified at its creation.
For example, you can pass in the initial API request for fields in the form:
"scenarioFields": { "eventname": "SQL Webinar", "eventurl": "https://events.sql.ru/" }
and output their value in an email message using DC methods in the form:
- {{user_guide:scenario:scenario_fields:scenariofield.eventname}}
- {{user_guide:scenario:scenario_fields:scenariofield.eventurl}}
respectively.
The user will receive a message of the form:
“Hello, you have signed up for the “SQL Webinar” event. The link to the event is: https://events.sql.ru/”