0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00
logto/packages/connector-twilio-sms
2022-07-04 14:58:52 +00:00
..
docs chore(connectors): config template md files to json files (#987) 2022-05-31 12:58:24 +08:00
src chore(connector): update connectors description (#1397) 2022-07-04 04:20:28 +00:00
CHANGELOG.md release: v1.0.0-alpha.0 2022-07-04 14:58:52 +00:00
jest.config.ts chore(connectors): remove unused jest-matcher-specific-error in connector packages (#1024) 2022-06-02 12:03:11 +08:00
logo.svg feat(core): serve connector logo (#931) 2022-05-24 13:54:37 +08:00
package.json release: v1.0.0-alpha.0 2022-07-04 14:58:52 +00:00
README.md docs(connector-twilio-sms): add Twilio SMS README.md (en-US) (#1284) 2022-06-29 15:36:41 +00:00
tsconfig.base.json feat(connector-twilio-sms): add twilio sms connector (#881) 2022-05-20 09:56:16 +08:00
tsconfig.build.json feat(connector-twilio-sms): add twilio sms connector (#881) 2022-05-20 09:56:16 +08:00
tsconfig.json chore(connectors): remove unused jest-matcher-specific-error in connector packages (#1024) 2022-06-02 12:03:11 +08:00
tsconfig.test.json feat(connector-twilio-sms): add twilio sms connector (#881) 2022-05-20 09:56:16 +08:00

Twilio short message service connector

Twilio provides programmable communication tools for making and receiving phone calls, sending and receiving text messages, and other communication functions. We can send the "verification code" text messages through its web service APIs.

Register Twilio account

Create a new account on Twilio. (Jump to the next step if you already have one.)

Set up senders' phone numbers

Go to the Twilio console page and sign in with your Twilio account.

Purchase a phone number under Phone Numbers -> Manage -> Buy a number.

Once we have a valid number claimed, nav to the Messaging -> Services. Create a new Message Service by clicking on the button.

Give a friendly service name and choose Notify my users as our service purpose. Following the next step, choose Phone Number as Sender Type, and link the phone number we just claimed to this service.

Note

Each phone number can only be linked with one messaging service.

Get account credentials

We will need the API credentials to make the connector work. Let's begin from the Twilio console page.

Click on the Account menu in the top-right corner, then go to the API keys & tokens page to get your Account SID and Auth token.

Back to Messaging -> Services settings page starting from the sidebar, and find the Sid of your service.

Compose the connector JSON

Fill out the accountSID, authToken and fromMessagingServiceSID fields with Account SID, Auth token and Sid of the corresponding messaging service.

You can add multiple SMS connector templates for different cases. Here is an example of adding a single template: - Fill out the content field with arbitrary string-typed contents. Do not forget to leave {{code}} placeholder for random passcode. - Fill out the usageType field with either Register, SignIn or Test for different use cases.

Here is an example of Twilio SMS connector config JSON.

{
    "accountSID": "<your-account-sid>",
    "authToken": "<your-auth-token>",
    "fromMessagingServiceSID": "<messaging-service-sid>",
    "templates": [
        {
            "content": "<arbitrary-register-template-contents: your passcode is {{code}}>",
            "usageType": "Register"
        },
        {
            "content": "<arbitrary-sign-in-template-contents: your passcode is {{code}}>",
            "usageType": "SignIn"
        },
        {
            "content": "<arbitrary-test-template-contents: your passcode is {{code}}>",
            "usageType": "Test"
        }
    ]
}

Config types

Name Type
accountSID string
authToken string
fromMessagingServiceSID string
templates Templates[]
Template Properties Type Enum values
content string N/A
usageType enum string 'Register' | 'SignIn' | 'Test'