Skip to content

The principle of scenarios

A scenario sends a sequence of emails to contacts entering a hosted database. Each trigger pairs a campaign with a delay, counted from the moment the contact is recorded in the database. Three triggers set to 0 days, 3 days and 10 days produce a three-message sequence, with no further intervention.

What the API does, and what it does not

This is the part to understand before writing any code: the API does not orchestrate scenarios, it feeds their database.

The scenario itself is built in the MDWorks interface. The hosted database, the campaigns, the triggers and their delays are all defined there, and no API call creates or modifies them. Your information system does not drive the sending logic: it adds contacts to the database, and the scenario takes over.

This split has a practical consequence. Changing a sequence, adding a follow-up message or adjusting a delay all happen in the interface, without touching your code. Conversely, a misconfigured scenario produces nothing visible on the API side: adding the contact succeeds, and no email goes out.

What must exist before your first call

Three items, in this order:

  1. The campaigns, created under “Automation”, “Email campaigns”. They are built like a regular message, with one difference: recipients cannot be edited, since it is the scenario trigger that imports them.
  2. The hosted database, with complex queries enabled. If the database does not appear when you create the scenario, that setting is almost always the reason. It sits in the “Structure” section of the database.
  3. The scenario, active, with at least one trigger. A scenario without a trigger exists, but sends nothing.

The interface side is covered in Create a scenario.

Bringing a contact into the scenario

All it takes is adding the contact to the scenario’s hosted database. Three calls do it:

CallAPIUse
list_insertRESTAdds contacts, several per call
list_insert_or_updateRESTAdds new contacts and updates the ones already there
Add a row to a databaseSOAPAdds one contact at a time

Importing a file, or a form linked to the database, has the same effect.

The database fields (last name, first name, custom fields) are available in every campaign of the sequence, not just the first one.

What happens after the contact is added

The countdown starts when the contact is recorded in the database, not when the scenario is created. Each trigger then fires at its own delay, give or take a few minutes: the scenario regularly checks for contacts that have reached their delay, so a trigger set to 0 days and 0 hours sends its campaign shortly after the contact is added.

Updating a contact that is already there, with list_insert_or_update, does not restart the sequence: its entry date in the database does not change.

Before each send, the scenario sets aside unsubscribed addresses, hard bounces and syntactically invalid addresses. These contacts stay in the database, but do not receive the campaign.

Each email sent by the scenario is deducted from your credit or your plan, like a single send through the API.

The log of messages actually sent is available in the interface, under the “History” section of the scenario.

Last updated on