django-herald
django-herald copied to clipboard
How to send notification via SMS and email
I'm wondering how you would recommended using django-herald so that notifications are sent via both SMS and email.
The users in my system will always have an email address, and 90% of them will also have a mobile phone number; both of these are set on my 'User' model. I will have many different types of notifications, and it would be good if I could define them once and have the notification always sent via email, and also via SMS if the user has a mobile phone number set. I plan to use Twilio for sending SMS messages.
Ideally I would want to be able to define the message/content of the notification in just one one place too, with the SMS message being just this plain text message, while the email gets rendered into a HTML email template with the message rendered in this template.
I'm trying to figure out the best way to approach this so that I don't have to create 2 copies of every notification type (one for email and one for SMS) and trigger 2 notifications every time I want to send a notification to a user. Any recommendations?
That is a very interesting idea. Somehow, I never thought about that. At the top of my head, I'm thinking you could create some sort of base class that mimics the TwilioTextNotification
class, but extends from the EmailNotificationClass
. That would be difficult to make work with storing in the database though.
We'll keep this issue open, and see if we can come up with a good way to solve this use case.