trigger.js
trigger.js
is configuration of JavaScript logic when trigger is executed.
It is executed when a trigger is received.
trigger.js
is used to compose the output result for it.
With input
variable, user can create their own logic for trigger.
Expected input/output
- Execution input
- Contains webhook event data.
- needs to follow the schema/variables configured in
data.json
. - data
- webhook event data
- Execution output
- output will contain result data needed for further executions.
- needs to follow the schema/output configured in
data.json
.
Example trigger.js
try {
const mailId = input.data.params.body.value[0].resourceData.id
const token = input.serivce.token
const response = await $.axios({
method: "get",
url: `https://graph.microsoft.com/v1.0/me/messages/${mailId}`,
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
}
})
let outlookEmail = response.data
return outlookEmail
} catch (error) {
throw error
}
Helpful?