Before you can use this extension, follow these steps to make the functions deployed for this extension publicly accessible:
- Go to the Cloud Functions dashboard for your project in the Google Cloud console.
- Click the checkbox next to the function called "ext-${param:EXT_INSTANCE_ID}-twilioSendOTP".
- If it's not already expanded, click Show Info Panel (in the top-right corner) to show the Permissions tab.
- Click Add Member. Then, in the New members field, enter the user "allUsers".
- Select the role Cloud Functions Invoker from the role dropdown list. You may need to type in this role's name to pull it into the list.
- Click Save.
- Repeat steps 2 to 6 for the function called "ext-${param:EXT_INSTANCE_ID}-twilioCheckOTP".
The above steps are required to prevent a CORS issue. Hence it is recommended, that you enforce authentication in the extension's configuration.
You can test the functions right away! (The code examples below use the Firebase JavaScript SDK. Please refer to the documentation to call functions from your app.
- Call the
ext-${param:EXT_INSTANCE_ID}-twilioSendOTP
function from your app like this:
functions.httpsCallable('ext-${param:EXT_INSTANCE_ID}-twilioSendOTP')({
number: "+919898989898", //E.164 Formatted number
channel: "sms" //Can be "sms" or "call"
}).then(result => console.log(result.data.status))
- When you receive the code, you can then call the
ext-${param:EXT_INSTANCE_ID}-twilioCheckOTP
function like this:
functions.httpsCallable('ext-${param:EXT_INSTANCE_ID}-twilioCheckOTP')({
number: "+919898989898", //E.164 Formatted number
code: "123456" //Code entered by the user
}).then(result => console.log(result.data.status))
The function will authenticate the code with Twilio Verify and then return an object with status
- which can be either "approved", "pending" or "canceled".
Usage of this extension also requires a Twilio account with the Twilio Verify service. You are responsible for any associated costs with your usage of Twilio and Firebase.
As a best practice, you can monitor the activity of your installed extension, including checks on its health, usage, and logs.