Package: az-messaging
AZ Messaging config[[TOC]]Install withpippipinstallaz-messagingsettings.pyINSTALLED_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',],},}Migratepython manage.py migrateSMSSupportSNS AWSTwilioHow to use it?Base on sample config, two sms send fromtwiliowithTWILIO_EE_SENDERnumber and one of them fromAWS-SNSand region iseu-west-1.fromazmessagingimportdefault_settingsassettingsfromazmessaging.modelsimportSMSNotificationTypeidentifier='what ever you want'message='Your code is: 1222'sms_type=SMSNotificationType.TRANSACTIONALklass=settings.READER.klass('sms',identifier)sms=klass(identifier=identifier,message=message,sms_type=sms_type)sms.set_receivers(['+16503331111','+37211123450','+37211123451'])sms.notify()TelegramHow to use it?fromazmessagingimportdefault_settingsassettingsidentifier='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 notificationHow to use it?fromazmessagingimportdefault_settingsassettingsidentifier='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()TODODocumentationSupport multiple providerSMS SupportSMS Support SNS AWSSMS Support TwilioSMS Routing Base on country/continentsSMS Support every provider you want.SMS BatchPush notificationConsoleWebsocketTelegramDevelopLicenseThe MIT License (MIT). Please seeLicense Filefor more information.