Skip to content

💧 Use Django admin to manage drip campaign emails using querysets on Django's User model.

License

Notifications You must be signed in to change notification settings

foundertherapy/django-drip-campaigns

 
 

Repository files navigation

Maintainability Test Coverage

Django Drip Campaigns

Build Status

Drip campaigns are pre-written sets of emails sent to customers or prospects over time. Django Drips lets you use the admin to manage drip campaign emails using querysets on Django's User model.

This project is a fork of the one written by Zapier.

Installation:

  1. Install django-drip-campaings using pip:
pip install django-drip-campaigns
  1. Add 'drip' to your INSTALLED_APPS list on your settings.
INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.comments',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',

    # ...

    'drip',
]
  1. (Optional) Set DRIP_FROM_EMAIL = '<your_app_from_email>' in your settings, where <your_app_from_email> is the email account that is going to be shown in the sent emails. Otherwise EMAIL_HOST_USER value will be used.
  2. (Optional) To support custom user model set DRIP_CAMPAIGN_USER_MODEL = '<your_app.model_name>' in your settings, and make sure to have a field or property named email in your custom model.
  3. Finally, run python manage.py migrate drip to set up the necessary database tables.

Usage

If you haven't, create a superuser with the Django createsuperuser command. Login with the admin user, and select Drips to manage them. You will be able to:

  • View created drips.
  • Create a new drip.
  • Select and delete drips.

Support SMS(Optional)

Since sending an sms can be done via several APIs, different ways and different conditions suitable to each project, we've decide to decoupled the code for sending sms using signals. Therefore,

  • In your signals.py use the post_drip signal receiver to handle the logic for sending the sms
from django.dispatch import receiver
from drip.signals import post_drip

@receiver(post_drip)
def handle_drip_sms(sender, **kwargs):
    drip = kwargs['drip']
    user = kwargs['user']
    # Get the message from the drip and the number from the user and handle the SMS message logic.
  • The sms text field supports user object injection, so you can use placeholders for the user data eg: This sms for {{user.first_name}}

Create Drip

In the Django admin, after select Drips, you can click on ADD DRIP + button to create a new one. You will see the add drip page:

Add Drip

On the FIELD NAME OF USER input, when you click on it, you will be able to view:

  • The fields of your user's model.
  • The fields of your user's model in other models that are related with it.

Please take a look a this example:

Lookup Fields

With this, you can select one or more fields to create useful drips.
Additionally if you select a field name of user that has a date type, you can enter in the FIELD VALUE input, a date value written in natural language that combines operations on the current datetime.
For example, if you have selected the field last_login that has a date type, and you want to create a drip to send emails to the users who logged in exactly one week ago; you can enter:

now-1 week

or

now- 1 w

Possible operations and values:

  • Add (+) or subtract (-) dates.
  • On the left side of the operation, write the current datetime value: now.
  • On the right side of the operation:
    • seconds or s.
    • minutes or m.
    • hours or h.
    • days or d.
    • weeks or w.
    • If you enter the number 1, you can write second, minute, etc.
    • Don't enter a space between now and the operation symbol. Optionally you can add (or not) a space around the number value.

Let's see some examples of the date values that you can enter:

  • now-1 day
  • now+ 8days
  • now+ 1 h
  • now-4hours
  • now- 3 weeks
  • now-1 weeks

View Timeline

In the Django admin, you can select a drip and then click on the VIEW TIMELINE button to view the mails expected to be sent with the corresponding receivers:

Timeline

Send drips

To send the created and enabled drips, run the command:

python manage.py send_drips

You can use cron to schedule the drips.

About

💧 Use Django admin to manage drip campaign emails using querysets on Django's User model.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 82.0%
  • HTML 6.9%
  • Makefile 5.8%
  • Batchfile 5.3%