Communication Actions
| Action | Description |
|---|---|
| Send verification code | Send 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| Delivery channel | Enum | Yes | The 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. |
| Scenario | Enum | Yes | What the code is for. Values come from the system enum Verification code scenario. See Scenarios. |
| Send to | Text | Yes | Phone 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:
| Scenario | Checked by |
|---|---|
register | Sign up (phone or email sign-up) |
login | Sign in (phone or email verification-code sign-in) |
reset | Reset password |
bind_account | Bind account (bind a phone number or email) |
unbind_account | Unbind account (unbind a phone number or email) |
delete | Delete 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
registerfails 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:
- Prerequisites:
- Enable Email verification under Action → Sign in.
- Create a page named
Register. - On the
Registerpage, add an Input component namedEmail Inputand a Button component namedSend Code Button.
- Select Component: On the
Registerpage canvas, select theSend Code Button. - Add Action: In the right panel, open the Action tab and add an action to On click.
- Configure Action:
- In the action menu, select Communication → Send verification code.
- Set Delivery channel to Email.
- Set Scenario to
register.
- Bind Parameters:
- Click the + button next to the Send to parameter.
- In the data source panel, select
Email Input->Value.
- Prerequisites:
-
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 Requeststoast.
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:
- Add the scenario
prize_drawunder Action → Verification code → Scenarios and sync backend changes. - 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.
- Add the scenario
-
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.