This workflow is the code that orchestrates tasks (through the Zenaton workflow engine) and executes them on your servers.
const { workflow, duration } = require("zenaton");
module.exports = workflow("OnboardingWorkflow", {
*handle(employee) {
const slack = this.connector('slack', 'your-slack-connector-id');
const sendgrid = this.connector('sendgrid', 'your-sendgrid-connector-id');
this.run.task("PreparePaperwork", employee)
const paperworkEvent = yield this.wait.event("PaperworkEvent");
if (paperworkEvent.success) {
this.run.task("SchedulePreOnboardingMeeting", employee)
const form = yield this.wait.event("OnboardingFormEvent");
accounts = yield this.run.task("CreateAccounts", employee, form.tools)
this.run.task("OfficeManagement", employee, form)
yield this.wait.for(duration.timestamp(form.onboardingDay));
sendgrid.post('/mail/send', {body: {"template_id": "welcome", ...}})
sendgrid.post('/mail/send', {body: {"template_id": "credentials", ...}})
slack.post('/api/chat.postMessage', {body: {"channel": "...", ...}})
sendgrid.post('/mail/send', {body: {"template_id": "onboarding_meetings", ...}})
} else {
this.run.task('CancelOnboarding', employee);
}
}
});
Real-world Examples
Start building workflows
Sign-up and run a sample project Learn more