Triggering Event Through Code Action

You can trigger an event using code actions, just like you can trigger an event using UI.

Using trigger cloud actions allows static content to be separated from your code, enabling flows that are based on more complex business rules or logic.

A code snippet to trigger an event is given below:

async payload => {
  trigger('EVENT_NAME')
}

Here is an example of a cloud code action that triggers two different flows depending on the current time:

async payload => {
  toolbelt.takeover()

  if(await toolbelt.isBusinessHours({ label: "livechat" })) {
    trigger('TAKEOVER_OFFICE_HOURS')
  } else{
    trigger('TAKEOVER_OUT_OF_OFFICE')
  }
}