---
# System prepended metadata

title: Event trigger logic

---

# Event trigger logic
![](https://i.imgur.com/Mtn8OgH.png)

## Collections in DB
![](https://i.imgur.com/hIESfpL.png)

### Collection filterOperators

| operatorId | description
| ---------- | -----------
| 0          | Equal
| 1          | Not equal
| 2          | Greater than

#### Schema:
```
{
    filterOperatorId: Number,
    name: String,
}
```

Example:
```{ filterOperatorId: 0, name: 'Equel' },```

### Collection eventTriggerFilters

| operatorId | description
| ---------- | -----------
| 0          | ProjectId
| 1          | Project name
| 2          | EntityId
| 3          | Less triggered duration
| 4          | Trigger count

Schema:
```
{
    filterId: Number,
    name: String,
}
```

Example:
```{ filterId: 0, name: 'ProjectId' },```

actions
### Collection actions

| operatorId | description | arguments
| ---------- | ----------- | ---------
| 0          | Send message| (toEntityId, messageObject, toPlatformId, optionalObject)

messageObject: 
> type - 'message'
```
{
    type: String,
    text: String
}
```
optionalObject
> botId - Specifies which bot to use to deliver the message
```
{
    botId: Number
}
```
#### Schema:
```
{
    actionId: Number,
    name: String,
    arguments: { actionArgumentId:Number, name: String }[]
}
```

Example:
```
{ 
    actionId: 0,
    name: 'Send message'
    arguments: [
        { actionArgumentId: 0, name: 'To entityId', isRequired: true },
        { 
            actionArgumentId: 2,
            name: 'Message',
            isRequired: true,
            subFields: [
                { actionArgumentId: 1, name: 'Message type', isRequired: true },
                { actionArgumentId: 1, name: 'Message text', isRequired: true }
            ]
        },
        { actionArgumentId: 0, name: 'To paltformId', isRequired: true },
        { 
            actionArgumentId: 2,
            name: 'optional',
            isRequired: false,
            subFields: [
                { actionArgumentId: 0, name: 'BotId', isRequired: false },
            ]
        },
    ]
}
```

### Collection actionArguments

| actionArgumentId | description
| ---------------- | -----------
| 0                | Number
| 1                | String
| 2                | Object

#### Schema
```
{
    actionArgumentId: Number,
    name: String
}
```
Example:
```{ actionArgumentId: 0, name: 'Number' }```

### Collection eventTriggers

#### Schema:
```
{
    eventTriggerId: Number,
    eventIds: Number[],
    filters: { 
        filterOperatorId: Number,
        filterId: Number,
        arguments: Any[],
    }[],
    customFilter: String,
    actions: {
        id: Number,
        arguments: Any[],
    }[]
}
```

Example:
```
{
    eventTriggerId: 67,
    eventIds: [47],
    filters: [
        {
            filterOperatorId : 0,
            filterId: 0, 
            arguments : [ 2 ]
        },{
            filterOperatorId : 0,
            filterId: 2, 
            arguments : [ {{entityId}}, 75 ]
        },{
            filterOperatorId : 0,
            filterId: 2, 
            arguments : [ {{entityId}}, 76 ]
        },{
            filterOperatorId : 2,
            filterId: 3,
            arguments: [1 * 60 * 1000]
        },{
            filterOperatorId : 0,
            filterId: 4,
            arguments: [0]
        }
    ],
	customFilter: '(0 OR 1) AND (3 OR 4)',
	actions: [
        {
		    id: 0,
		    arguments: [ 789, { type: 'message', text: 'message'}, 8 ]
		},{
			id: 0,
			arguments: [ 789, { type: 'text', text: 'message'}, 2 ]
		}
	]
}
```