OMNI¶
Scenario creation¶
To create OMNI-campaign scenario it is required to call POST /omni-task-api/tasks, sending scenario parameters in the request body with authorization data in the header.
Request parameters¶
| Parameter | Data type | Description |
|---|---|---|
| addressBookSource (optional) |
AddressBookSource | Address book settings. Can not be used for transactional messages, where contacts are specified separately. Macros (fields) from address books can be used in message texts. |
| channel | string | Campaign channel. Possible values: The |
| draftId (optional) |
integer | Email draft ID. |
| taskInfo (optional) |
TaskInfo | Scenario type, which activates the triggered mailing. |
| taskName | string | The campaign name. From 1 to 100 characters. |
| triggers | Triggers | Trigger options. |
| type | string | Campaign type. Possible values: |
AddressBookSource¶
| Parameter | Data type | Description |
|---|---|---|
| addressBookSourceType | string | Address book type, used for filters. Possible values: |
| byOptimalSendTime (optional) |
boolean | Personalized sending time. When you select this option, contacts will receive emails at the calculated personalized time. The campaign can last about 24 hours from the moment of launch. |
| byTimeZone (optional) |
boolean | Taking into account local contact time when sending. |
| checkDuplicate (optional) |
boolean | Check for duplicate contacts in the address book. The messages will not be sent to the duplicates. |
| contactCountId (optional) |
integer | Contact number ID in the address book. |
| contactGroupIds | array[integer] | Contact group IDs array in the address book. Is not used with the segmentIds parameter. |
| stopContactGroupIds (optional) |
array[integer] | Contact stoplist IDs array. The messages will not be sent to these contacts. |
| period (optional) |
string | Campaign frequency. Used when "type": "PERIODIC".Possible values: |
| segmentIds (optional) |
array[integer] | Segment IDs array within contact groups of the address book if the contact group is segmented. Is not used with the contactGroupIds parameter. |
| smoothSendMinutes (optional) |
integer | Smooth sending, set in minutes. Minimum value: 0 |
TaskInfo¶
| Parameter | Data type | Description |
|---|---|---|
| scenarioType (optional) |
string | Scenario type. Used with "type": "EVENT_FLOW".Message will be sent if user abandoned: |
Triggers¶
| Parameter | Data type | Description |
|---|---|---|
| channel | string | Trigger channel. Possible values: |
| type | string | Trigger type. Possible values: |
| index | integer | Trigger ID. |
| parentIndex (optional) |
integer | Parent trigger ID. You can configure the trigger sequence with this parameter. |
| startTime (optional) |
datetime | Trigger start date. The format is YYYY-MM-DD hh:mm:ss. |
| endTime (optional) |
datetime | Trigger end date. The format is YYYY-MM-DD hh:mm:ss. |
| eventSources (optional) |
array[EventSources] | Events array for sending campaigns. |
| eventCollectorSettings (optional) |
EventCollectorSettings | Repeated event campaign parameters. This type of events can be canceled only by other triggers. |
| geoSettings (optional) |
GeoSettings | Geo-campaigns parameters. |
| noEventSourceSettings (optional) |
NoEventSourceSettings | Contains the parameter: The event is set in a separate trigger, in the EventSources object. The index of this trigger must be specified in |
| template | Template | Message templates array. |
EventSources¶
| Parameter | Data type | Description |
|---|---|---|
| channel (optional) |
string | Trigger channel. Possible values: |
| eventType | string | Event type. Possible values: |
| eventValue (optional) |
string | Events that trigger the campaign. ○ ○ ○ |
EventCollectorSettings¶
| Parameter | Data type | Description |
|---|---|---|
| maxNewRegisterSec (optional) |
integer | Time after the event in seconds. During that time the campaign will not be repeated. |
| onlyUpdateEventSources (optional) |
array[EventSources] | The events array for repeated campaigns. After these events, the countdown will start in the maxNewRegisterSec parameter. If the event repeats, the countdown will start again. |
GeoSettings¶
| Parameter | Data type | Description |
|---|---|---|
| antiFraudMins (optional) |
integer | The time in minutes to resend the message. |
| locationIds (optional) |
array[integer] | Location IDs array. |
| pushApplicationIds (optional) |
array[integer] | Application IDs array which will provide the campaign. |
Template Filling¶
Tip
In message texts, you can use the Freemarker markup language to use the contact attributes and create dynamic content.
| Template | Description |
|---|---|
| smsTemplate (optional) |
SmsTemplate |
| viberTemplate (optional) |
ViberTemplate |
| emailTemplate (optional) |
EmailTemplate |
| pushTemplate (optional) |
PushTemplate |
| pushWalletTemplate (optional) |
PushWalletTemplate |
| whatsAppTemplate (optional) |
WhatsAppSendMessageRequest |
| vkTemplate (optional) |
VkTemplate |
SmsTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| shortenUrl (optional) |
boolean | If For example, if the parameter is enabled, the link
|
| from | string | Approved sender’s name. |
| text | string | Message text: ○ up to 17085 characters using Cyrillic. ○ up to 34170 characters using Latin. |
| validity | integer | Lifetime of the message in seconds. Minimal value: 0 |
ViberTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| from | string | Sender's name used when sending the message. Only the senders' names which are available for using by the user can be used. |
| action (optional) |
string | URL or deep link to which the user will go after clicking the button. The parameter is also used to specify the URL of the attached video or file. Button can only be used in a combination with other parameters. |
| caption (optional) |
string | Button text, no more than 30 characters in UTF-8 encoding. |
| image (optional) |
string | URL for the image in JPG, JPEG or PNG formats. |
| text (optional) |
string | The message text, UTF-8 characters. The standard number of characters is no more than 1000. If the standard number of characters in a Viber message exceeds 1000 characters, the message will be split into segments, which will be delivered successively, preserving the semantic content. |
| validity (optional) |
integer | Lifetime of the message in seconds. Minimal value: 15 |
EmailTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| sourceAddress | string | Sender's email address. The domain must first be created and approved. |
| sourceName | string | Sender's name. Up to 150 characters. |
| subject | string | Email subject. |
| htmlBody | string | Email body in HTML format. |
| plainText (optional) |
string | Email body in Plaintext format, all tags are displayed as plain text. |
| AttachmentsIds (optional) |
array[string] | Files array attached to the letter. |
PushTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| from | integer | Approved sender's ID. |
| title | string | Notification heading. The maximum length is 200 characters. |
| text | string | Notification text. The maximum length is 1024 characters. |
| badge (optional) |
integer | The key that sets the value for the application badge - the icon with a number in the upper corner of the application icon. The number indicates unread notifications in the application. You can set any integer. |
| validity (optional) |
integer | Lifetime of the notification in seconds. Minimum value: 30 Maximum value: 86400, 1 day Default value: 86400, 1 day |
| platform (optional) |
string | Platform or operating system of devices to which the notification will be sent. Available values: |
| silentPush (optional) |
boolean | If true, the notification will not be displayed on the recipient's device. False by default. |
| options (optional) |
object | An object with the data which will be specified in the callback with the message status. Any |
| apns (optional) |
object | Fields, which are specific for iOS device. |
| android (optional) |
object | Fields, which are specific for Android device. |
PushWalletTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| from | string | Approved sender's ID. |
| payload | PushPayload | Message content settings. |
| callbackUrl (optional) |
string | The URL to which the system will send notifications about message status changes. Any valid URL with the |
| callbackData (optional) |
object | An object with the data which will be specified in the callback with the message status. Any |
| mergeKey (optional) |
string | Key to combine request and response. |
| validity (optional) |
integer | Notification lifetime in seconds. |
VkTemplate¶
| Parameter | Data type | Description |
|---|---|---|
| routes | array | List of possible transport channels separated by comma ○ Delivery is made before the physical device firstly gets the notification. When specifying several transport channels, only one of the channels will be eventually used. The sequence and logic of the selected routes is configured when connecting to the system. If the parameter is not specified, all possible delivery methods are used by default. The delivery will occur only if a certain group in the corresponding social network is specified in the template. For example, if only the VK group is specified in the template, then delivery to Odnoklassniki group using this template will not occur. |
| delivery_policy | string | Possible values: By default If If |
| validity (optional) |
integer | Lifetime of the message in seconds. Minimal value: 60 If the message is not delivered within the |
| templateId (optional) |
integer | Message template ID in Devino. |
| templateData | object | JSON-object, where keys are the variable names in the template. For example, for the template: |
| callbackData (optional) |
object | An object with the data which will be specified in the callback with the message status. Any |
| callbackUrl (optional) |
string | The URL to which the system will send callbacks when the message status changes. Any valid URL with the |
Request examples¶
{
"taskName": "NEW_SMS",
"type": "SIMPLE",
"channel": "SMS",
"addressBookSource": {
"contactGroupIds": [111],
"addressBookSourceType": "SIMPLE",
"period": "ONCE"
},
"triggers": [
{
"index": 321,
"startTime": "2020-06-02 11:00:00",
"endTime": "2020-06-02 12:00:00",
"type": "ADDRESS_BOOK_SOURCE",
"channel": "SMS",
"eventSources": [
{
"channel": "SMS",
"eventType": "STATE",
"eventValue": "delivered"
}
],
"template": {
"smsTemplate": {
"text": "We opened a new shop!",
"from": "TEST",
"validity": 600
}
}
}
]
}
We send a message through SMS. If it is delivered, the campaign ends. If it is not delivered, we send an Email.
{
"taskName": "Campaign repeat",
"type": "SIMPLE",
"channel": "EMAIL",
"addressBookSource": {
"contactGroupIds": [111],
"addressBookSourceType": "SIMPLE",
"period": "ONCE"
},
"triggers": [
{
"index": 11,
"startTime": "2019-11-29T09:33:57.595Z",
"endTime": "2019-11-29T19:33:57.595Z",
"type": "ADDRESS_BOOK_SOURCE",
"channel": "SMS",
"template": {
"smsTemplate": {
"text": "First message",
"from": "TEST",
"validity": 600
}
}
},
{
"index": 12,
"parentIndex": 11,
"startTime": "2019-11-29T19:33:57.595Z",
"endTime": "2019-11-29T23:33:57.595Z",
"type": "NO_EVENT_SOURCE",
"channel": "EMAIL",
"eventSources": [
{
"channel": "SMS",
"eventType": "STATE",
"eventValue": "delivered"
],
"noEventSourceSettings": {
"stateWaitMaxTimeSec": 6000
},
"template": {
"emailTemplate": {
"htmlBody": "Second message if first was not delivered",
"sourceAddress": "test@test",
"sourceName": "TEST",
"subject": "Test message"
}
}
}
]
}
If the user did not have time to fill the application on the site, after 100 seconds of waiting, we send an Email.
If the user has not completed filling out the application in a day, we send another Email. If the user has completed the application filling, we complete the event and do not send anything.
{
"taskName": "Suggestion to complete the application filling",
"type": "EVENT_FLOW",
"channel": "EMAIL",
"triggers": [
{
"index": "0",
"type": "EVENT_COLLECTOR",
"channel": "EMAIL",
"eventCollectorSettings": {
"maxNewRegisterSec": 86400,
"onlyUpdateEventSources": [
{
"eventType": "CONTACT_WEB_EVENT"
}
]
},
"eventSources": [
{
"eventType": "CONTACT_WEB_EVENT",
"eventValue": "RequestToCompleteApplication"
}
]
},
{
"index": "1",
"parentIndex": "0",
"type": "EVENT_COLLECTOR",
"channel": "EMAIL",
"eventSources": [
{
"eventType": "CONTACT_WEB_EVENT",
"eventValue": "CompletedApplication"
}
]
},
{
"index": "2",
"parentIndex": "0",
"type": "NO_EVENT_SOURCE",
"channel": "EMAIL",
"noEventSourceSettings": {
"stateWaitMaxTimeSec": 100
},
"template": {
"emailTemplate": {
"htmlBody": "Complete the application filling",
"sourceAddress": "test@test",
"sourceName": "TEST",
"subject": "Test message"
}
}
}
]
}
Response parameters¶
| Parameter | Data type | Description |
|---|---|---|
| result | string | Scenario data array. To be given with |
| result.code | string | Shows the result of scenario processing. |
| result.result | string | Created scenario ID. |
| reasons | array | An array of the errors which have occurred while processing the scenario. |
| reasons.key | string | Error code. |
| description | string | Message with error description. |
Response example¶
{
"result": {
"code": "OK",
"result": "7003"
}
}
{
"result": null,
"reasons": [
{
"key": "contactGroupIds.or.segmentIds.absent"
}
],
"description": "Validation error: contactGroupIds or segments absent"
}
Receiving scenarios¶
To receive OMNI scenarios you can use two methods:
- GET /omni-task-api/tasks/{taskId} to receive one scenario with its ID.
- GET /omni-task-api/tasks to receive scenarios sorted by filters.
In both methods headers it is required to specify the authorization data.