entry
You can create a workflow that will be triggered when a new email arrives. This is done by creating a function emailReceived
which will be called when an email arrives. The function will receive a context object (ctx
) as its parameter.
function emailReceived(ctx) {
// Your code here
}
When interacting with workflow events, callback functions receive a context object (ctx
) that contains information about the current state:
For message handlers:
ctx.email.body
: The body of the emailctx.email.subject
: The subject of the emailctx.email.from
: The sender address of the email.ctx.email.to
: The recipient address of the email.ctx.email.cc
: The CC address of the email.ctx.email.bcc
: The BCC address of the email.ctx.email.emailId
: The ID of the email.ctx.email.replyEmailId
: The ID of the email to which this email is a reply.ctx.email.receivedTime
: The Time when the email was receivedctx.email.direction
: The direction of the emailctx.email.queueId
: The queue ID of the emailctx.email.language
: The detected language of the email, if language detection is enabledctx.email.ticketId
: The ticket ID that the email belongs to
Example
In this example, the workflow stops if the email is a reply to a previous email.
function emailReceived(ctx) {
if (ctx.email.replyEmailId !== 0) {
console.log('This is a reply, skipping...')
return;
}
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.