Document Validation

This Workflow illustrates how to implement a document validation process using a third party API/service to verify a user's identity based on the documents that they upload.

Visual of Workflow

This flowchart is a visual representation of the different tasks in the workflow.

Workflow Steps

  • A user signs up and opens an account and is prompted to upload their documents
  • According to the account type, some additional documents may be needed. In this example, the user must upload 2 documents : an ID and a proof of address
  • After 3 days, if the user has not uploaded the documents, a reminder is sent to tell them that they must import the remaining documents
  • We’ll send a maximum of 3 reminders spaced 3 days apart
  • If the user does not import their documents the account will not be opened, and we would email the user to notify them that they needs to sign in again and create the account
  • When a user does import the documents, we would check with our third party service to make sure that they are valid
  • If the documents are not valid, we would notify the user by email and tell them the reason
  • When the documents have been validated, we will notify the user that the process is complete

Workflow Code

This workflow is the code that orchestrates the tasks through the Zenaton workflow engine and are then executed on your servers. Tasks will be dispatched as soon as a user is prompted to upload their documents and the tasks will be executed "behind the scenes" on your workers.

const { workflow } = require('zenaton')

module.exports = workflow('DocumentValidationWorkflow', {
  *handle(requestId) {
    const sendgrid = this.connector('sendgrid', 'your-connector-id');

    this.requestId = requestId
    this.counter = null

    let remainingReminders = 3
    const request = yield"GetRequestInformation", this.requestId);
    this.counter = request.documents.length

    while (this.counter > 0 && remainingReminders > 0) {
      const event = yield this.wait.event("ProofReceivedEvent").for(duration.days(3));

      if (!event) {
        mail_template_params = {
          body: {
            "template_id": "reminder"
            "personalizations": [
                "subject": `Still ${this.counter} documents to upload`,
                "to": [ { "email": } ],
                "dynamic_template_data": {
                  "requestId": requestId,
                  remainingReminders": remainingReminders,
        }'/mail/send', mail_template_params)


    if (this.counter === 0) {'/mail/send', {body: {"template_id": "valiation_success", ...}})
    } else {'/mail/send', {body: {"template_id": "validation_failed", ...}})

  *onEvent(name, {
    if (name === 'ProofReceivedEvent') {
      if (data.isValid) {

Workflow Executions

View the real-time tasks executions of this workflow.