sydevs / Atlas

Central database of worldwide meditation classes
6 stars 5 forks source link

Send event verification messages via WhatsApp #63

Open Ardnived opened 2 years ago

Ardnived commented 2 years ago

We should allow managers to provide a WhatsApp number, and choose that as their communication preference. This is particularly for messagings asking them to verify that their program is still up to date. Some yogis don't have email, or are more responsive via WhatsApp.

Bonus: maybe support SMS or other messaging services?

Ardnived commented 2 years ago

@dbackeus Do you have any experience working with the WhatsApp Business API (and specifically with Heroku).

It seems like WhatsApp's docs says we would have to set up 2 additional containers on Heroku. First off, not sure how that would work without creating our own buildpack - since I haven't been able to find one. But secondly, if we did, that sounds like it would require 2 more dynos, and therefore $14/mo.

If true, I was thinking about whether it would be worthwhile to use a third party service that handles WhatsApp messages (and maybe SMS/other services as a bonus). Have you used any of those services as well and have any recommendations?

dbackeus commented 2 years ago

Never worked with WhatsApp Business API. Judging by their marketing page for it (https://www.whatsapp.com/business/api) I would expect just getting access to be potentially expensive (makes it clear the target audience is "medium to large businesses" and no free sign up), but maybe I'm missing something.

With regards to SMS https://www.twilio.com is probably the most convenient service for that. I've done a basic SMS sending integration using that in the past and it's easy to get going. The cost will scale with number of subscribers though. Sending SMS, unlike email, has a base cost associated to it's never going to be ridiculously cheap.

Looks like Twilio integrates with WhatsApp Business API so potentially a good option for an all in one solution: https://www.twilio.com/whatsapp

Another approach for WhatsApp interaction might be to set up WhatsApp groups for programs and then use regular bots to send messages to those groups. I haven't built WhatsApp bots but I'm assuming it would be free (apart from hosting costs) similar to Slack / Telegram bots.

dbackeus commented 2 years ago

Oh, didn't realize WhatsApp didn't even have open bot support:

Screenshot 2022-01-30 at 14 16 26

(via https://botsociety.io/blog/2018/09/whatsapp-bot)

Not a big fan of WhatsApp and the Facebook Meta enterprise to be honest 😐

Ardnived commented 2 years ago

Thanks @dbackeus. Yeah, not a fan either, but unfortunately it's so prevalent - especially for Indian yogis we were suggested it would be more reliable than Email.

Ardnived commented 2 years ago

MessageBird appears to be an excellent candidate for this solution, as well as being a useful option for responding to user queries for We Meditate in general. However, before this can be progress, we need @antontcymbal to set up the WhatsApp Business Profile, which required a Facebook Business Manager login. https://dashboard.messagebird.com/en/getting-started/whatsapp-embedded/start

Ardnived commented 2 years ago

Currently progress on this is blocked by a bug with the MessageBird gem. https://github.com/messagebird/ruby-rest-api/issues/71

We could work around this with direct api calls.

dbackeus commented 2 years ago

FWIW I tend to always roll my own HTTP clients these days instead of depending on random API wrapper gems which all work differently / use different underlying HTTP clients and are generally 10x more complicated than a single file HTTP wrapper using eg. typhoeus would be.

Ardnived commented 2 years ago

@dbackeus Yeah, I ended up doing the same for the Klaviyo API calls. I've been using HTTParty. Is there any reason you prefer typhoeus over that (or other gems).

dbackeus commented 2 years ago

Typhoeus has top tier performance and a very clean API which has made it my go-to http client. It also supports things like "basic auth as part of URL" out of the box which not all HTTP clients do.

HTTParty is an unnecessary abstraction IMO, but I do see the allure for those looking for a more object oriented feel. I personally tend to prefer a non class based approach for HTTP clients since HTTP is essentially state-less so simple module methods tend to do the trick.

Looking forward there might be something to be said for newer HTTP clients with native support for Ruby 3.x fiber scheduler but I haven't had the need to go look at them yet.

Ardnived commented 2 years ago

We now have a sample implementation of the messagebird api in master - which works with the WhatsApp sandbox. I'll need Anton to set up the WhatsApp business account, before we can move this to the next step.