-
Notifications
You must be signed in to change notification settings - Fork 68
Replace Auth0 Rules with Auth0 Actions #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
218a109
791d509
339eec1
420dfa4
2b72d1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| title: "Sample Use Cases: Actions with Passwordless Authentication" | ||
| description: Learn how to use Actions to customize passwordless authentication flows, including routing SMS and email OTPs through custom providers. | ||
| validatedOn: 2026-06-26 | ||
| --- | ||
|
|
||
| With [Actions](/docs/customize/actions/actions-overview), you can extend [passwordless connections](/docs/authenticate/passwordless) by routing SMS and email OTP delivery through custom providers. Auth0 Actions give you control over which phone and email services handle your authentication messages. | ||
|
|
||
| ## Send passwordless email with a custom email provider | ||
|
|
||
| When a user [authenticates through a passwordless email connection](/docs/authenticate/passwordless/authentication-methods/email-otp), Auth0 triggers the `custom-email-provider` Action to deliver the OTP. Use this Action to route messages through any email service. | ||
|
|
||
| To configure the Action, navigate to [**Branding > Email Provider**](https://manage.auth0.com/#/templates/provider) and select the **Custom Provider** option. To learn more, read [Configure an Email Provider with a Customized Action](/docs/customize/email/smtp-email-providers/custom/configure-action). | ||
|
|
||
| ```javascript lines | ||
| /** | ||
| * Handler called when Auth0 needs to deliver a passwordless email OTP. | ||
| * @param {Event} event - Details about the notification. | ||
| * @param {CustomEmailProviderAPI} api - Methods for controlling notification behavior. | ||
| */ | ||
| exports.onExecuteCustomEmailProvider = async (event, api) => { | ||
| try { | ||
| const response = await fetch('https://api.example.com/send-email', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Authorization': `Bearer ${event.secrets.API_KEY}`, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify({ | ||
| to: event.notification.to, | ||
| from: event.notification.from, | ||
| subject: event.notification.subject, | ||
| html: event.notification.html, | ||
| text: event.notification.text, | ||
| }), | ||
| }); | ||
|
|
||
| if (response.status >= 500) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems odd to me, i would think this is going to miss all 4xx responses and return as delivered? we may want to update the retry logic here |
||
| api.notification.retry(`Server error from email provider: ${response.status}`); | ||
| return; | ||
| } | ||
| } catch (error) { | ||
| api.notification.drop(`Unexpected error: ${error.message}`); | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| To learn more about available event properties, read [Actions Triggers: custom-email-provider - Event Object](/docs/customize/email/smtp-email-providers/custom/action-triggers-custom-email-provider-event-object). | ||
|
|
||
| ## Send passwordless SMS with a custom phone provider | ||
|
|
||
| When a user [authenticates through a passwordless SMS connection](/docs/authenticate/passwordless/authentication-methods/sms-otp), Auth0 triggers the `custom-phone-provider` Action to deliver the OTP. Use this Action to route messages through any SMS provider. | ||
|
|
||
| To configure the Action, navigate to [**Branding > Phone Provider**](https://manage.auth0.com/dashboard/#/phone/templates/phone/provider) and select the **Custom** option. To learn more, read [Configure a Custom Phone Provider](/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider). | ||
|
|
||
| ```javascript lines | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may want to add something like, "in the provider configuration, add" so it doesn't just jump into code for them |
||
| /** | ||
| * Handler called when Auth0 needs to deliver a passwordless SMS OTP. | ||
| * @param {Event} event - Details about the notification. | ||
| * @param {CustomPhoneProviderAPI} api - Methods for controlling notification behavior. | ||
| */ | ||
| exports.onExecuteCustomPhoneProvider = async (event, api) => { | ||
| const response = await fetch('https://api.example.com/messages', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Authorization': `Bearer ${event.secrets.API_KEY}`, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify({ | ||
| to: event.notification.recipient, | ||
| from: event.notification.from, | ||
| body: event.notification.as_text, | ||
| }), | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| api.notification.retry(`Failed to send SMS: ${response.status}`); | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| To learn more about available event properties, read [Actions Triggers: custom-phone-provider - Event Object](/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider/actions-triggers-custom-phone-provider-event-object). | ||
|
|
||
| ## Learn more | ||
|
|
||
| * [Configure an Email Provider with a Customized Action](/docs/customize/email/smtp-email-providers/custom/configure-action) | ||
| * [Configure a Custom Phone Provider](/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider) | ||
| * [Configure a Custom Phone Provider with Twilio Verify](/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider/configure-a-custom-phone-provider-with-twilio-verify) | ||
| * [Set Up Custom SMS Gateway for Passwordless Connections](/docs/authenticate/passwordless/authentication-methods/use-sms-gateway-passwordless) | ||
| * [Use the Unified Phone Experience for Passwordless](/docs/customize/phone-messages/unified-phone/unified-phone-experience-passwordless) | ||
| * [Passwordless Connections Best Practices](/docs/authenticate/passwordless/best-practices) | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use my own (toggled) > custom > custom provider settings needs URL, then code in config. Need more steps here i'd think