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 ThirdPartyPasswordless from "supertokens-node/recipe/thirdpartypasswordless";
import Session from "supertokens-node/recipe/session";
import { TwilioService } from "supertokens-node/recipe/passwordless/smsdelivery";
supertokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [
ThirdPartyPasswordless.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/thirdpartypasswordless"
"github.com/supertokens/supertokens-golang/recipe/thirdpartypasswordless/tplmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
smsService, err := thirdpartypasswordless.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{
thirdpartypasswordless.Init(tplmodels.TypeInput{
SmsDelivery: &smsdelivery.TypeInput{
Service: smsService,
},
}),
},
})
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import thirdpartypasswordless
from supertokens_python.ingredients.smsdelivery.types import SMSDeliveryConfig, TwilioSettings
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
thirdpartypasswordless.init(
sms_delivery=SMSDeliveryConfig(
service=thirdpartypasswordless.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.