Skip to Content

Communication Actions

ActionDescription
Send verification codeSend a six-digit code for a given scenario to a phone number or email address. The code remains valid for five minutes.

Send verification code

Send a six-digit verification code for a given scenario to a phone number or email address. The code remains valid for five minutes and must then be checked by the matching action or by the Check verification code node. For an end-to-end walkthrough, see Send and check verification codes.

Use cases

  • Verify a user’s identity before sign-up, sign-in, password reset, binding or unbinding a phone number or email address, or account deletion.
  • Confirm a sensitive custom operation, such as a prize draw or a withdrawal, together with a custom scenario.

Parameters

ParameterTypeRequiredDescription
Delivery channelEnumYesThe System group contains built-in Email. The Custom group lists the channels added under Action → Verification code → Delivery channels. Use a custom channel to send codes by SMS.
ScenarioEnumYesWhat the code is for. Values come from the system enum Verification code scenario. See Scenarios.
Send toTextYesPhone number or email address that receives the code. Hidden when Scenario is delete, in which case Momen sends the code to the phone number or email address bound to the signed-in user.

Scenarios

The scenario used to check a code must match the one used to send it. Momen ships six built-in scenarios, each checked automatically by its action:

ScenarioChecked by
registerSign up (phone or email sign-up)
loginSign in (phone or email verification-code sign-in)
resetReset password
bind_accountBind account (bind a phone number or email)
unbind_accountUnbind account (unbind a phone number or email)
deleteDelete account

For any other purpose, add a custom scenario under Action → Verification code → Scenarios and sync backend changes. Scenario names may contain only letters, digits, and underscores, and cannot start with a digit, for example prize_draw or withdraw_confirm. Check codes sent for a custom scenario with the Check verification code node in an Actionflow.

Results

  • Result: None
  • On success: Runs after Momen generates and sends the code.
  • On failure: Runs when delivery fails, for example because the recipient is missing or invalid, the matching sign-in method is disabled, or codes are requested too often.

How it works

  • Code generation: Momen generates a six-digit code and stores it with the recipient and the selected scenario for five minutes. Sending a new code to the same recipient for the same scenario replaces the previous code, which stops working immediately.
  • Delivery:
    • With built-in Email, Momen sends the code through its own email service.
    • With a custom channel, Momen runs the channel’s Actionflow and passes it the recipient, the code, and the scenario name. The Actionflow delivers the code through your provider.
  • Single use: A code is invalidated as soon as an action or the Check verification code node checks it successfully.
  • Limitations:
    • Prerequisite: Sending by SMS requires Phone verification, and sending by email requires Email verification, to be enabled under Action → Sign in. Otherwise the request fails.
    • One-minute cooldown: With built-in email, requests for the same recipient and the same scenario must be at least one minute apart. Requests made during the cooldown return a rate-limit error. Each scenario has its own cooldown. Custom channels have no cooldown, so add your own rate limiting in the delivery Actionflow.
    • Scenario matching: A code can only be checked against the scenario it was sent with. For example, a code sent with register fails when used to sign in, even if the digits are correct.

Custom delivery channels

To send codes through a custom channel, create a delivery Actionflow and add a channel for it under Action → Verification code → Delivery channels. See Deliver codes through your own provider.

Errors

  • Automatic error toast: When delivery fails, Momen enters On failure and also displays an error toast, such as Too Many Requests. Avoid adding another toast for the same error unless you want to replace the default feedback.

Examples

Send a verification code during registration

  • Goal: On the registration page, the user enters their email address and clicks the “Send Code” button to receive a six-digit verification code.

  • Configuration:

    1. Prerequisites:
      • Enable Email verification under Action → Sign in.
      • Create a page named Register.
      • On the Register page, add an Input component named Email Input and a Button component named Send Code Button.
    2. Select Component: On the Register page canvas, select the Send Code Button.
    3. Add Action: In the right panel, open the Action tab and add an action to On click.
    4. Configure Action:
      • In the action menu, select Communication → Send verification code.
      • Set Delivery channel to Email.
      • Set Scenario to register.
    5. Bind Parameters:
      • Click the + button next to the Send to parameter.
      • In the data source panel, select Email Input -> Value.
  • Outcome: The user receives a six-digit code by email and can use it with Sign up. Triggering the action again during the one-minute cooldown displays a Too Many Requests toast.

Send a code before a prize draw

  • Goal: Before entering a prize draw, a signed-in user receives a code at their own email address.

  • Configuration:

    1. Add the scenario prize_draw under Action → Verification code → Scenarios and sync backend changes.
    2. Add Communication → Send verification code to the “Get code” button, set Delivery channel to Email, set Scenario to prize_draw, and bind Send to to the current user’s email address.
  • Outcome: The code is checked by the Check verification code node in the prize draw Actionflow. See Use a custom scenario: confirm a prize draw by email.

Last updated on