Skip to main content

A django based automaton do a sms messaging.

Project description

What this?

My first project in python/django.

This app was writen for automate a SMS messaging to customers based on a RFM matrix. The SMS is sent when a trigger works (a customer move down on a R-axis).

How works it?

Upload your database which contain deals of customers. It must be in a CSV format. Columns are in order bellow. | Data Deal | Customer Name | Customer Phone | Product | Price | At an import the app checks customers to phones.

After upload your base, heed to go into settings of created table and you need to set RFM settings. Create rules of messaging on triggers which you need. Personalize your message using {name}.

A cron compute a RFM every customer at night, and if a move on the R-axis is done, the customer get a message in the day.

Summary, your have automaton which comeback your customer to you, again, and again, and your bank account full more, and more.

Attention: All the templates are implemented in russian language.

Quick start

  1. Install and config PostgreSQL, create a user and a database.

  2. Install Redis from there https://redis.io/.

3. Install Django and Start a new project, config a backend use the Postgres credentials like this

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',
        'USER': 'user_name',
        'PASSWORD': 'user_password',
        'HOST': '127.0.0.1',
        'PORT': '5432'
    }
}

4. Run

pip install django-rfmizer

5. Add next apps to your INSTALLED_APPS in settings.py

INSTALLED_APPS = [
    'rfmizer.apps.RfmizerConfig', # This string must be add in a first element of a the list
    '...',
    'fixture_magic',
    'multiselectfield',
    'django_celery_beat',
    ]

6. Add into settings.py a code is below

LOGIN_REDIRECT_URL = '/profile/'

7. Add import into urls.py

from django.contrib.auth.views import LoginView
from django.urls import include, path

8. Include the rfmizer URLconf in your project urls.py like this

urlpatterns += [
    path('registration/', include('django.contrib.auth.urls', )),
    path('', include('rfmizer.urls')),
    path('login/', LoginView.as_view(redirect_authenticated_user=True),
         name='login')
]

9. Create a celery.py file in main directory and insert to it a code below, NAME_OF_DIRECTORY is a directory which contain this file and the settings.py

import os
from celery import Celery
from celery.schedules import crontab

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NAME_OF_DIRECTORY.settings')

celery_app = Celery(
    'rfmzer',
    broker='redis://localhost:6379/0',
    backend='redis://localhost:6379/0',
    include=['rfmizer.tasks'],
)

# If you need, it can to be changed.
celery_app.conf.timezone = 'UTC'

celery_app.conf.beat_schedule = {
    'run-rfmizer-at-3-am': {
        'task': 'rfmizer.tasks.schedule_run_rfmizer',
        'schedule': crontab(hour='3', day_of_week='mon-fri')
    },
    'run-sms-sending-at-10-am': {
        'task': 'rfmizer.tasks.schedule_run_sms_sending',
        'schedule': crontab(hour='10', day_of_week='mon-fri')
    },
}
  1. Run $ python manage.py migrate to create the rfmizer models.

10. Run in a different terminals on server, NAME_OF_DIRECTORY is a directory which contain the celery.py. It must be run from a directory where the manage.py file is.

redis-sever
celery -A NAME_OF_DIRECTORY worker -l INFO
celery -A NAME_OF_DIRECTORY beat -l INFO
python manage.py runserver
  1. Visit http://127.0.0.1:8000/

Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-rfmizer-0.2.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_rfmizer-0.2-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file django-rfmizer-0.2.tar.gz.

File metadata

  • Download URL: django-rfmizer-0.2.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.3

File hashes

Hashes for django-rfmizer-0.2.tar.gz
Algorithm Hash digest
SHA256 59ad082f230a5ae2341b1ce93d7fdd9869dc2faa69804b8b09a953d501909e2a
MD5 52e5911904dbb16b664d907b90df30c4
BLAKE2b-256 da6a78dd9566e18919035cc9359afbb5f7ca442dc1934826f19223cf6a45c2cf

See more details on using hashes here.

File details

Details for the file django_rfmizer-0.2-py3-none-any.whl.

File metadata

  • Download URL: django_rfmizer-0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.3

File hashes

Hashes for django_rfmizer-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85003f0be9d875b0432160a463b4b872a11dd1c4ee363316bc30b83a6dc4aa2d
MD5 57d86345b90f0b53d7b3cd4edb05723e
BLAKE2b-256 835654c857badc66109cddacf3ef8ee2e1769fd144ec973023c3880a364eeb41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page