Twilio configuration
Using this method, you can:
- Send emails using your own domain
- Optionally customise the default email templates and subject.
- 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: { accountSid: "...", authToken: "...", opts: { // optionally extra config to pass to Twilio client },
// give either from or messagingServiceSid from: "...", messagingServiceSid: "...", }, }) }, }), Session.init() ]});
import ( "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{ AccountSid: "...", AuthToken: "...", // Pass only one of From or MessagingServiceSid From: "...", MessagingServiceSid: "...", }, }) 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.ingredients.smsdelivery.types import SMSDeliveryConfig, TwilioSettings
init( app_info=InputAppInfo( api_domain="...", app_name="...", website_domain="..."), framework='...', recipe_list=[ passwordless.init( sms_delivery=SMSDeliveryConfig( service=passwordless.TwilioService( twilio_settings=TwilioSettings( account_sid="...", auth_token="...", opts={ # Optional configs to pass to twilio client },
# give either from_ or messaging_service_sid from_="...", messaging_service_sid="...", ) ) ) ) ])
To learn about how to customise the SMS templates, please see the next section.