Phone Number Verification for User Accounts (SMS)

Hello Anvil Community!

I’ve created a single full-fledged app on Anvil for my university’s capstone project that live syncs product data for many simultaneous users. Anvil seems to have all the robust features and integrations I would need to create a full-fledged business, including: Stripe payment processing, account creation, outside account linking, Google maps integration, etc. However, there seems to be no built in SMS option to verify a user’s phone number.

This is the only valid way to prevent people from spam creating accounts, and thus spamming requests. I’m sure there’s an external API I could integrate accordingly, but it’d be nice if almost 100% of account handling is done via Anvil, including SMS verification. So, has anybody tackled this challenge before? What have you done? Or what are some recommendations for how to go about verifying phone numbers? I’m not looking for alternatives to phone numbers at the moment.

Thanks!

1 Like

I think there might be some SMS Integrations in the Forum, but it’s easier to just use email verification as you can see on this page:

That unfortunately only verifies emails and has NOTHING to do with phone number verification. A user can create a new gmail account in less than one minute manually, then spam requests to my app, quickly causing me to loose functionality. Thus, ensuring expensive query calls are only done one person at a time requires more extensive verification. The easiest form of advanced verification is likely phone numbers. Though, with SAML verification, perhaps an external service could do the SMS verification for me. However, that’s an extra hurdle I’d hate to put my users through.

Yes I know it’s not the same, I’m just suggesting what I know is available in anvil and at least similar to what you asked for.

I do know there’s no out of box anvil solution for sms, and i suggested email verification especially since it’s a school project.

Since it’s capstone you fell like you need to integrate SMS, feel free, but for your problem, I wouldn’t even for my production apps. just my two cents, take it or leave it :slight_smile:

This is NOT for an educational project. I was simply bringing up my background, though I may have been unclear. The capstone project was my old, finished app. I’d like to take that app the next step further towards full publishing. SMS verification is necessary for a full-fledged application to be published and monetized, though my emphasis is on helping people with a free service. Thus why I can’t afford spam requests for free user accounts. I’m surprised Anvil Works hasn’t done anything to prevent spam user accounts :frowning:, you’d think this is an extremely common issue. I appreciate your response @duncan_richards12 :slight_smile:. I’ll let the community know if I find an external service I’m able to easily integrate SMS into.

Since your Anvil server-side code is standard Python, you might try the Python Package Index’s search feature. Findings will need further refinement according to your specific needs, but it’s a place to start.

Here’s a simple way to implement this by yourself

  1. Check option for disabling user account by default in users service

  2. Create a UI that takes phone number, email and password. Send this to the server.

  3. On the server, signup the user by the email and password. But the account will be disabled.

  4. Use some SMS API on server to send OTP. Keep that otp saved in your Anvil server session storage

  5. On the client, ask for the OTP. Verify it with the saved otp on the session storage. If the otp is the same, enable the user account.

This code is of course untested and there is a possibility I may have overlooked something. But these are the general steps

2 Likes

That is probably the best architecture to accomplish this task. I will update on what I decide to use for SMS verification.

Thanks for your input!

1 Like