Skip to main content

GitHub GitHub GitHub

AZ Messaging config

[[TOC]]

Install with pip

pip install az-messaging

settings.py

INSTALLED_APPS = [
   # ....
   'azmessaging',
   # ...
]

AZ_MESSAGING = {
   'SETTING_VALUE_READER_CLASS': 'azmessaging.readers.DefaultReader',
   'CLASS': {
       'SMS': 'azmessaging.channels.SMSNotificationChannel',
       'TELEGRAM': 'azmessaging.channels.TelegramNotificationChannel',
       'PUSH': 'azmessaging.channels.PushNotificationChannel',
   },
   'TELEGRAM': {
       'SERVICE_PROVIDER': {
           'DEFAULT': {
               'CLASS': 'azmessaging.telegram.TELEGRAMAPIDefaultAPI',
               'api_key': os.environ.get('TELEGRAM_DEFAULT_API_KEY', None),
               'api_server': os.environ.get('TELEGRAM_DEFAULT_API_SERVER', None),
           },
       },
       'DEFAULT_SERVICE_PROVIDER': 'DEFAULT',  # REQUIRED
       'PRIORITY_SERVICE_PROVIDER': [  # REQUIRED
           'DEFAULT',
       ],
   },
   'SMS': {
       'SERVICE_PROVIDER': {
           'SNS': {
               'CLASS': 'azmessaging.sms.SMSAPISNSAmazon',
               'ROUTING': [
                   {
                       'countries': 'UK, US',
                       'region_name': 'eu-west-1'
                   },
                   {
                       'continents': 'EUROPE, AFRICA',
                       'region_name': 'eu-west-2'
                   }
               ],
               'key_id': os.environ.get('AWS_ACCESS_KEY_ID', None),
               'access_key': os.environ.get('AWS_SECRET_ACCESS_KEY', None),
               'region_name': os.environ.get('AWS_SNS_DEFAULT_REGION', None),
           },
           'TWILIO': {
               'CLASS': 'azmessaging.sms.SMSAPITwilio',
               'ROUTING': [
                   {
                       'countries': 'DE, EE',
                       'sender': os.environ.get('TWILIO_EE_SENDER', None),
                   },
                   {
                       'continents': 'ASIA',
                       'sender': os.environ.get('TWILIO_ASIA_SENDER', None),
                   }
               ],
               'account_sid': os.environ.get('TWILIO_ACCOUNT_SID', None),
               'auth_token': os.environ.get('TWILIO_AUTH_TOKEN', None),
               'sender': os.environ.get('TWILIO_DEFAULT_SENDER', None),
           },
       },
       'DEFAULT_SERVICE_PROVIDER': 'SNS',  # REQUIRED
       'PRIORITY_SERVICE_PROVIDER': [      # REQUIRED
           'TWILIO',
           'SNS',
       ],
       'WHITE_LIST': '__all__',    # EXAMPLE = 'COUNTRY_CODE_1, COUNTRY_CODE_2' 
       'BLACK_LIST': '__none__',   # EXAMPLE = '__all__' OR 'COUNTRY_CODE_3, COUNTRY_CODE_4'
   },
   'PUSH': {
       'SERVICE_PROVIDER': {
           'FCMDJANGO': {
               'CLASS': 'azmessaging.pushnotifications.fcmdjango.FCMDjangoAPI',
               'api_key': os.environ.get('FCM_SERVER_KEY', None),
           },
       },
       'DEFAULT_SERVICE_PROVIDER': 'FCMDJANGO',  # REQUIRED
       'PRIORITY_SERVICE_PROVIDER': [  # REQUIRED
           'FCMDJANGO',
       ],
   },
}

Migrate

python manage.py migrate

SMS

Support

  1. SNS AWS
  2. Twilio

How to use it?

Base on sample config, two sms send from twilio with TWILIO_EE_SENDER number and one of them from AWS-SNS and region is eu-west-1.

from azmessaging import default_settings as settings
from azmessaging.models import SMSNotificationType
identifier = 'what ever you want'
message = 'Your code is: 1222'
sms_type = SMSNotificationType.TRANSACTIONAL
klass = settings.READER.klass('sms', identifier)
sms = klass(identifier=identifier, message=message, sms_type=sms_type)
sms.set_receivers(['+16503331111', '+37211123450', '+37211123451'])
sms.notify()

Telegram

How to use it?

from azmessaging import default_settings as settings
identifier = 'what ever you want'
message = 'Your code is: 1222'
klass = settings.READER.klass('telegram', identifier)
telegram = klass(identifier=identifier, message=message)
telegram.set_receivers(['user_a', 'user_b', ])
telegram.notify()

Push notification

How to use it?

from azmessaging import default_settings as settings
identifier = 'what ever you want'
message = 'Your code is: 1222'
title = 'OTP'
image_url = 'https://example.com/1.png' 
klass = settings.READER.klass('push', identifier)
push_notification = klass(identifier=identifier, message=message, title=title, image_url=image_url, payload_data={})
push_notification.set_receivers(['user_a', 'user_b', ])
push_notification.notify()

TODO

  • Documentation

  • Support multiple provider

  • SMS Support

  • SMS Support SNS AWS

  • SMS Support Twilio

  • SMS Routing Base on country/continents

  • SMS Support every provider you want.

  • SMS Batch

  • Push notification

  • Console

  • Websocket

  • Telegram

Develop

License

The MIT License (MIT). Please see License File for more information.

Metadata

Release files for az-messaging 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for az-messaging 1.3.0
File Size Uploaded
az-messaging-1.3.0.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for az-messaging 1.3.0
File Interpreter ABI Platform
az_messaging-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 kB

Release files / az-messaging-1.3.0.tar.gz

Download URL az-messaging-1.3.0.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
24c510bb3daa2a93a0e52dc635d8b5d6dc27eb18817117769268ec91eb73ad4a
BLAKE2b-256 checksum
How to use checksums
08892c3bd1ae7c928269468fb8aea875646a64b060c7c9d98e62291e18262998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11

Release files / az_messaging-1.3.0-py3-none-any.whl

Download URL az_messaging-1.3.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8746ce0d9d42128864c9b1344df9323f998ed581110a54db0984b56d665354d
BLAKE2b-256 checksum
How to use checksums
93171ec7dbae7841ef5408045d542bf2e01f7e1102135fa3d531d46cfea36d23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.11

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page