Skip to main content
Version: 7.1.0

route.js

route.js is configuration of JavaScript logic for routing the event to trigger.

With input variable, user can create their own logic for routing.

result should have "trigger" field, contains trigger name as a string.

After the execution of route, trigger.js of trigger will be executed.

Expected input/output

  • Execution input
    • input/notification contains received event notification.
  • Execution output
    • e.g
      • { target: automationId, trigger: "email.received" }
    • output need to contain trigger and target.
      • trigger:
        • trigger name for execute
      • target:
        • target Subscription(Automation) id

Example route.js

try {

// Response for validation token when creating subscription
if (input.notification.params.query.validationToken) {
return {
}

} else {
// Response for notification
const automationId = input.notification.params.body.value[0].clientState
const chnageType = input.notification.params.body.value[0].changeType

if (chnageType === "created") {
return {
target: automationId,
trigger: "email.received"
}
} else if (chnageType === "updated") {
// email.sent and email.updated
return {
target: automationId,
}
} else if (chnageType === "deleted") {
return {
target: automationId,
trigger: "email.deleted"
}
}
}
} catch (error) {
throw error;
}