Skip to main content

Change SMS content

To change the content of the default SMS templates, you can override the getContent function in the smsDelivery object. It allows you to return an object that has the following properties:

  • body: This is the email's body. This can be HTML or just text as well.
  • toPhoneNumber: The phone number where the SMS will be sent to.
import supertokens from "supertokens-node";import Passwordless from "supertokens-node/recipe/passwordless";import Session from "supertokens-node/recipe/session";import { TwilioService } from "supertokens-node/recipe/passwordless/smsdelivery";
supertokens.init({    appInfo: {        apiDomain: "...",        appName: "...",        websiteDomain: "..."    },    recipeList: [        Passwordless.init({            smsDelivery: {                service: new TwilioService({                    twilioSettings: { /*...*/ },                    override: (originalImplementation) => {                        return {                            ...originalImplementation,                            getContent: async function ({                                codeLifetime, // amount of time the code is alive for (in MS)                                phoneNumber,                                urlWithLinkCode, // magic link                                userInputCode, // OTP                            }) {                                // send some custom SMS content                                return {                                    toPhoneNumber: phoneNumber,                                    body: "SMS BODY"                                }
                                // You can even call the original implementation and                                // modify its content:
                                /*let originalContent = await originalImplementation.getContent(input)                                originalContent.body = "My custom body";                                return originalContent;*/
                            }                        }                    }                })            }        }),        Session.init()    ]});
Which frontend SDK do you use?
supertokens-web-js / mobile
supertokens-auth-react