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.
- NodeJS
 - GoLang
 - Python
 
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()    ]});import (    "fmt"
    "github.com/supertokens/supertokens-golang/ingredients/smsdelivery"    "github.com/supertokens/supertokens-golang/recipe/passwordless"    "github.com/supertokens/supertokens-golang/recipe/passwordless/plessmodels"    "github.com/supertokens/supertokens-golang/supertokens")
func main() {    smsService, err := passwordless.MakeTwilioService(smsdelivery.TwilioServiceConfig{        Settings: smsdelivery.TwilioSettings{ /* ... */ },        Override: func(originalImplementation smsdelivery.TwilioInterface) smsdelivery.TwilioInterface {            // originalGetContent := *originalImplementation.GetContent
            (*originalImplementation.GetContent) = func(input smsdelivery.SmsType, userContext supertokens.UserContext) (smsdelivery.SMSContent, error) {                // amount of time the code is alive for (in MS)                codeLifetime := input.PasswordlessLogin.CodeLifetime                phoneNumber := input.PasswordlessLogin.PhoneNumber
                // magic link                urlWithLinkCode := input.PasswordlessLogin.UrlWithLinkCode
                // OTP                userInputCode := input.PasswordlessLogin.UserInputCode                fmt.Println(codeLifetime)                fmt.Println(phoneNumber)                fmt.Println(urlWithLinkCode)                fmt.Println(userInputCode)
                // send some custom email content                return smsdelivery.SMSContent{                    Body:          "SMS BODY",                    ToPhoneNumber: phoneNumber,                }, nil
                // Or you can call the original implemenation and change its content:                /*                   originalResponse, err := originalGetContent(input, userContex)                   if err != nil {                       return smsdelivery.SMSContent{}, nil                   }                   originalResponse.body = "SMS Body"                   return originalResponse                */            }
            return originalImplementation        },    })    if err != nil {        panic(err)    }
    supertokens.Init(supertokens.TypeInput{        RecipeList: []supertokens.Recipe{            passwordless.Init(plessmodels.TypeInput{                SmsDelivery: &smsdelivery.TypeInput{                    Service: smsService,                },            }),        },    })}from supertokens_python import init, InputAppInfofrom supertokens_python.recipe import passwordlessfrom supertokens_python.recipe.passwordless.types import TwilioOverrideInput, SMSTemplateVarsfrom supertokens_python.ingredients.smsdelivery.types import SMSDeliveryConfig, SMSContent, TwilioSettingsfrom typing import Dict, Any
def custom_sms_content_override(original_implementation: TwilioOverrideInput) -> TwilioOverrideInput:
    # original_get_content = original_implementation.get_content
    async def get_content(template_vars: SMSTemplateVars, user_context: Dict[str, Any]) -> SMSContent:        # amount of time the code is alive for (in MS)        _ = template_vars.code_life_time        phone_number = template_vars.phone_number        __ = template_vars.url_with_link_code  # magic link        ___ = template_vars.user_input_code  # OTP
        # send some custom email content        return SMSContent(body="EMAIL BODY", to_phone=phone_number)
        # you can even call the original implementation and modify that
        # original_content = await original_get_content(template_vars, user_context)        # original_content.body = "My custom body"        # return original_content
    original_implementation.get_content = get_content    return original_implementation
init(    app_info=InputAppInfo(        api_domain="...", app_name="...", website_domain="..."),    framework='...',      recipe_list=[        passwordless.init(            sms_delivery=SMSDeliveryConfig(                service=passwordless.TwilioService(                                        twilio_settings=TwilioSettings(...),                      override=custom_sms_content_override                )            )        )    ])