Saltar al contendio prinicipal

Triggers & Contexts

Advertencia

Esta página aún no se encuentra traducida al español.

COTLang Data Extraction


design

Overview

Each time an automation is triggered, a snapshot is taken of its context, i.e., the relative data that surrounds the trigger.

For example, if a user executes a slash command, i.e., a special written message in a channel workspace that triggers a bot to carry out a routine, the context of that trigger is stored. The data context of the automation executed by the slash command will include:

  • the channel data in which the slash command was executed,
  • the message data that was sent in the channel and triggered the bot,
  • and finally, a string of any special command arguments added to the slash command sent in the message.

Contexts are stored in JSON format and follow the Cotalker data model schemas. The example explained above is known as the Slash Command Trigger, which gets its data context from the COTChannel and COTMessage data models.

The table below indicates the different sources or triggers and their corresponding contexts.

You can use COTLang to extract data from the triggered event contexts in order carry out further automations. For example, in a state survey trigger (i.e., State Start Form) routine, you can get direct access to the task's data which can be used in other stages of the routine.

tip

See the Context Language Description section for a brief explanation of the values shown in the table below.

Contexts Table

Source:

Slash Command Trigger

Context:

{
channel: COTChannel,
message: COTMessage,
cmdArgs: Array[string]
}

Description:

The source is a bot that is triggered with a slash command and is associated with a particular channel: /command

Source:

Global Slash Command Trigger

Context:

{
channel: COTChannel,
message: COTMessage,
cmdArgs: Array[string]
}

Description:

The source is a global bot that is triggered in any channel with a slash command: /command

Source:

Channel Survey Trigger

Context:

{
...COTAnswer,
messages: COTMessage
}

Description:

A Channel Survey Trigger is a bot that is triggered with a specific type of survey sent in a specific channel.

Source:

Global Survey Trigger

Context:

{
...COTAnswer,
messages: COTMessage
}

Description:

Global Survey Trigger is a bot that is triggered with a specific type of survey sent in any channel.

Source:

Schedule

Context:

// Custom body.

Description:

A Scheduler is an event that can be executed at a specific time (non-recurring) or at pre-established intervals (recurring).

Source:

Workflow Start

Context:

{
answer: COTAnswer,
meta: {
parentTask: ObjectId[COTTask],
taskGroup: ObjectId[COTTaskGroup]
}
}

Description:

A survey is triggered before starting a new workflow. The survey can be created and configured for new workflow initialization.

Source:

Post Workflow Start

Context:

{
task: COTTask,
parent: COTTask
}

Description:

Post workflow start is triggered after a workflow is started.

Source:

State Survey Trigger

Context:

{
...COTTask,
sentAnswer: COTAnswer
}

Description:

State Survey Triggers are triggered within any task by a specific survey and at specific states (see State Start Form for more information).

Source:

Changed State

Context:

{
...COTTASK
}

Description:

Changed State is triggered when a task changes state.

Source:

Service-Level Agreement (SLA)

Context:

{
taskId: ObjectId[COTTask],
taskGroupId: ObjectId[COTTaskGroup],
ChannelID: ObjectId[COTChannel]
}

Description:

SLAs are time-triggered events based on how much time a task is in a specific state.


Context Language Description

Brief explanation of the values used in the Contexts Table.

  1. ... : Destructuring operator, i.e., each key is merged into the parent object.

    For example:

    If COTExample is:

    { _id: ObjectId, content: String }

    then

    { ...COTExample, someKeyName: Number }

    represents

    { _id: ObjectId, content: String, someKeyName: Number }

  1. Array[T]: is an array of type T.

    For example:

    Model

    { commands: Array[String] }

    can contain

    { commands: ["hello", "world"] } 

  1. COTChannel Data model

  1. COTMessage Data model

  1. COTAnswer Data model

  1. COTTask Data model

  1. COTTaskGroup Data model

  1. ObjectID[T]: 24-character unique identifier that represents an object of type T