{
  "version": "4.0.0",
  "form": {
    "name": "Email OTP verification with Auth0 Email Provider",
    "languages": {
      "primary": "en"
    },
    "nodes": [
      {
        "id": "step_qJEB",
        "type": "STEP",
        "coordinates": {
          "x": 422,
          "y": -100
        },
        "alias": "Email verification",
        "config": {
          "components": [
            {
              "id": "rich_text_Cqas",
              "category": "BLOCK",
              "type": "RICH_TEXT",
              "config": {
                "content": "<h2>Check your email</h2><p>Please enter the 6-digit verification code that was sent to <strong>{{context.user.email}}</strong>. The code is valid for 5 minutes.</p>"
              }
            },
            {
              "id": "verification_code",
              "category": "FIELD",
              "type": "NUMBER",
              "label": "Verification code",
              "required": true,
              "sensitive": false
            },
            {
              "id": "next_button_BtEe",
              "category": "BLOCK",
              "type": "NEXT_BUTTON",
              "config": {
                "text": "Continue"
              }
            },
            {
              "id": "resend_button_7eih",
              "category": "BLOCK",
              "type": "RESEND_BUTTON",
              "config": {
                "active_text": "Didn't receive the code?",
                "button_text": "Resend",
                "waiting_text": "Resend in {{remaining_seconds}} seconds",
                "text_alignment": "CENTER",
                "flow_id": "#FLOW-1#",
                "max_attempts": 3,
                "waiting_time": 60
              }
            }
          ],
          "next_node": "flow_hq3b"
        }
      },
      {
        "id": "flow_hq3b",
        "type": "FLOW",
        "coordinates": {
          "x": 982,
          "y": 52
        },
        "config": {
          "flow_id": "#FLOW-2#",
          "next_node": "$ending"
        }
      },
      {
        "id": "flow_3Qle",
        "type": "FLOW",
        "coordinates": {
          "x": 56,
          "y": 56
        },
        "config": {
          "flow_id": "#FLOW-1#",
          "next_node": "step_qJEB"
        }
      }
    ],
    "start": {
      "next_node": "flow_3Qle",
      "coordinates": {
        "x": -197,
        "y": 41
      }
    },
    "ending": {
      "resume_flow": true,
      "coordinates": {
        "x": 1357,
        "y": 29
      }
    }
  },
  "flows": {
    "#FLOW-1#": {
      "name": "Generate OTP & Send email",
      "actions": [
        {
          "id": "generate_otp",
          "type": "OTP",
          "action": "GENERATE_CODE",
          "allow_failure": false,
          "mask_output": false,
          "params": {
            "reference": "{{context.user.email}}",
            "length": 6
          }
        },
        {
          "id": "send_email",
          "type": "AUTH0",
          "action": "SEND_EMAIL",
          "allow_failure": false,
          "mask_output": false,
          "params": {
            "to": "{{context.user.email}}",
            "subject": "{{custom_vars.code}} is your verification code",
            "body": "{% if user.nickname %}\n<p>Hello {{user.nickname}},</p>\n{% else %}\n<p>Hello,</p>\n{% endif %}\n<p>{{custom_vars.code}} is your verification code</p>",
            "custom_vars": {
              "code": "{{actions.generate_otp.code}}"
            }
          }
        }
      ]
    },
    "#FLOW-2#": {
      "name": "Verify OTP & Update user",
      "actions": [
        {
          "id": "verify_otp",
          "type": "OTP",
          "action": "VERIFY_CODE",
          "allow_failure": false,
          "mask_output": false,
          "params": {
            "reference": "{{context.user.email}}",
            "code": "{{fields.verification_code}}"
          }
        },
        {
          "id": "if_then_condition_mnXT",
          "alias": "Is it valid?",
          "type": "FLOW",
          "action": "BOOLEAN_CONDITION",
          "allow_failure": false,
          "mask_output": false,
          "params": {
            "if": {
              "operands": [
                {
                  "operands": [
                    "{{actions.verify_otp.valid}}",
                    true
                  ],
                  "operator": "EQ"
                }
              ],
              "operator": "AND"
            },
            "then": [
              {
                "id": "update_user_IPZP",
                "type": "AUTH0",
                "action": "UPDATE_USER",
                "allow_failure": false,
                "mask_output": false,
                "params": {
                  "connection_id": "#CONN-1#",
                  "user_id": "{{context.user.user_id}}",
                  "changes": {
                    "email_verified": true
                  }
                }
              }
            ],
            "else": [
              {
                "id": "show_error_message_Whan",
                "type": "FLOW",
                "action": "ERROR_MESSAGE",
                "allow_failure": false,
                "mask_output": false,
                "params": {
                  "message": "We're sorry, your verification code is not valid. Please, review it and try it again."
                }
              }
            ]
          }
        }
      ]
    }
  },
  "connections": {
    "#CONN-1#": {
      "id": "ac_eaWfppxMiU8AWncCDwaMA9",
      "app_id": "AUTH0",
      "name": "REPLACE_WITH_M2M_CONNECTION"
    }
  }
}