Information about Contributing Regional SMS Provider (via Send SMS HTTP Hook)
Regional SMS Senders
We're accepting contributions for regional SMS providers via the Send SMS Hook.
Contributors for select SMS providers (e.g. msg91 (@MeetChaudhari) and Africa's Talking (@mutumbakato) ) can add the following lines to your config.toml on the latest version of the CLI to enable the hook locally. If you are interested in contributing a regional provider for a hook which is not msg91 or Africa's Talking please make a comment with the provider name below.
Note that this feature is only available for use with the CLI locally - it will be available on Supabase projects once we merge the frontend
[auth.hook.send_sms]
enabled = true
uri = "http://host.docker.internal:54321/functions/v1/sms_sender"
secret = "env(SEND_SMS_HOOK_SECRET)"
This configuration assumes we're using a Supabase Edge Function which is called sms_sender though in practice you can use any HTTP endpoint of your choosing. With respect to the secret, it should take the form v1,whsec_<standard-base64-string>. You can use a generic base64 encoding tool to help generate the base64 string.
You can view the wip docs and example README for details about HTTP Hooks. You can use the JSON Schema Faker Tool in tandem with the Send SMS JSON Schema provided in order to generate a fake payload to test the function with.
Let us know if there's anything unclear or if there are any further questions or concerns. Thanks!
Details About Contributing
Contributing Format
We may feature some of the functions on our Edge Function Guides - if you wish for your regional sender to be considered, please paste a link to a Github repository containing a README.md, an .env.local file, and an index.ts file containing the function content. We will then check with the appropriate team to see whether it would fit into the guides.
Here's the README outline:
Your-edge-function-name
- What does this edge function do?
- When would I want to use it?
Example:
Use this Hook with the Send SMS Extension Point to send a message with an AppHash via Twilio Programmable Messaging. The App Hash identifies a mobile application and is embedded it an SMS to allow an Android application to determine that the message was intended for the Application. In turn, this allows for the App to fetch specific information, such as OTP codes, to perform autofill so that the user does not have to exit the application to retrieve information from a message.
Configuration
- What env vars do I need to add to .env.local?
- Where do I find these env vars?
Example:
Copy the following environment variables from the Twilio Console into your .env.local file:
TWILIO_ACCOUNT_SID=""
TWILIO_AUTH_TOKEN=""
TWILIO_PHONE_NUMBER=""
Testing
- Include an example cURL function with which we can test the edge function
Any other points of note?
- As needed.
Hey @J0. I noticed that the HTTP hooks UI has been merged—thank you for your efforts on this! However, I'm encountering an issue: I'm unable to connect the edge function to Authentication as a hook. It seems that the hooks currently only accept database functions. Is there anything specific I need to do to establish this connection to the Edge functions?
Thank you for your assistance.
Hey @mutumbakato,
Apologies on the delayed reply - it's merged but currently behind a feature flag. Should be unflagged once the docs go in
Thanks for the update, I'll be waiting for the actual release.
@J0 Any update on this? Can see sms hook in UI, But not firing. Any update would be helpful. Thank you.
Hey @shaharyarrahmad,
Yup that is correct - it is behind a feature flag. We're done with the implementation for the most part but need to release the docs and go through the implementation. I know it has taken quite a while but it is coming soon.
Do check back mid Aug - in the meantime feel free to use the locally hosted version or let us know if there's a specific provider you'd like to see so we can look into examples or similar
Thank tou @J0 .. looking forward to it.
hi everyone, we've just released the "Send SMS" hook - you can check out the following links:
Hey Kang, thanks a lot for shipping this, it's going to be very helpful. I've been trying it out and I realised that I still can't enable phone auth provider without selecting one of the listed phone providers. It there any other way I can do this?
@mutumbakato thanks for raising this - i've made a fix for it here so it should work properly now (https://github.com/supabase/supabase/pull/28706)
Hey Guys, I'm trying to use "Send SMS" hook, on self-hosted supabase. currently I added these to my docker-compose.yml and .env files as well GOTRUE_EXTERNAL_PHONE_ENABLED: true GOTRUE_HOOK_CUSTOM_SMS_PROVIDER_ENABLED: true GOTRUE_HOOK_CUSTOM_SMS_PROVIDER_URI: http://host.docker.internal:8000/functions/v1/send_sms GOTRUE_HOOK_CUSTOM_SMS_PROVIDER_SECRET: v1,whsec_9XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
but gives me this error AuthApiError: Unable to get SMS provider
can you help me to figure out this.
Hey @dileeshaupview,
Thanks for the update and detailed email. Surfacing this here so that others may learn as well. Can you share your .env or .toml file?
Specifically, wondering if you have GOTRUE_SMS_PROVIDER="<provider>" set and also what the version of the auth service you're running.
You can check the version by running docker ps . It should be contained in the image tag
Hi Joel,
Thanks for the feedback! Here's a quick update based on your suggestions:
-
I have now updated all Supabase images to the latest versions through docker-compose.yml, including the auth service, which was updated from supabase/gotrue:v2.151.0 to v2.158.1.
-
I wanted to clarify regarding the GOTRUE_SMS_PROVIDER="
" setting, should I need to add this, and if so, what value should I be entering as the provider?
I'll continue testing and will report back on further progress.
Thanks again for your help!
Hi @dileeshaupview ,
Can you try these configurations in your docker-compose.yml file?
GOTRUE_HOOK_SEND_SMS_ENABLED: "true"
GOTRUE_HOOK_SEND_SMS_URI: "http://host.docker.internal:8000/functions/v1/send-sms"
GOTRUE_HOOK_SEND_SMS_SECRETS: "v1,whsec_VGhpcyBpcyBhbiBleGFtcGxlIG9mIGEgc2hvcnRlciBCYXNlNjQgc3RyaW5n"
You won't be needing the GOTRUE_SMS_PROVIDER setting. Also, note that true must be wrapped with double quotations.
Hi @dileeshaupview ,
Can you try these configurations in your
docker-compose.ymlfile?GOTRUE_HOOK_SEND_SMS_ENABLED: "true" GOTRUE_HOOK_SEND_SMS_URI: "http://host.docker.internal:8000/functions/v1/send-sms" GOTRUE_HOOK_SEND_SMS_SECRETS: "v1,whsec_VGhpcyBpcyBhbiBleGFtcGxlIG9mIGEgc2hvcnRlciBCYXNlNjQgc3RyaW5n"You won't be needing the
GOTRUE_SMS_PROVIDERsetting. Also, note thattruemust be wrapped with double quotations.
Thank you so much for your help! This is Working
Hi @dileeshaupview ,
Can you try these configurations in your
docker-compose.ymlfile?GOTRUE_HOOK_SEND_SMS_ENABLED: "true" GOTRUE_HOOK_SEND_SMS_URI: "http://host.docker.internal:8000/functions/v1/send-sms" GOTRUE_HOOK_SEND_SMS_SECRETS: "v1,whsec_VGhpcyBpcyBhbiBleGFtcGxlIG9mIGEgc2hvcnRlciBCYXNlNjQgc3RyaW5n"You won't be needing the
GOTRUE_SMS_PROVIDERsetting. Also, note thattruemust be wrapped with double quotations.
Hi. I have the error "Failed to send magic link: Error unmarshaling Send SMS output" when I click to "Send OTP" button.
@ankenu it's possible your hook is returning an error response (anything else other than status code 200). can you confirm the hook you configured is accessible and sending a successful response?
@ankenu it's possible your hook is returning an error response (anything else other than status code 200). can you confirm the hook you configured is accessible and sending a successful response?
Thank you for your answer. You were right. The error was that the function returned an empty object. There is an error on line 78 in the documentation.