Sending SMS from django app - python

I came to the requirement to send SMS from my django app. Its a dashboard from multiple clients, and each client will have the ability to send programable SMS.
Is this achievable with django smsish? I have found some packages that aren't updated, and I sending email sms is not possible.
All answers found are old and I have tried all approaches suggested.
Do I have to use services like twilio mandatorily? Thanks

Using Twilio is not mandatory, but I do recommend it. Twilio does the heavy lifting, your Django App just needs to make the proper API Requests to Twilio, which has great documentation on it.
Twilio has Webhooks as well which you can 'hook' to specific Django Views and process certain events. As for the 'programmable' aspect of your app you can use django-celery, django-cron, RabbitMQ or other task-queueing software.

Related

Python: WhatsApp Cloud API webhook

I have a WhatsApp business account with a number linked to it. I want some way to receive messages using python from it. I couldn't find a solution that doesn't require online hosting(heroku, glitch, twilio ect.).
Whatsapp cloud API will request you a webhook to post the messages received on the number you linked to the business account.
You can expose a webhook listener selfhosted without the need to use a hosting provider. For obvious reasons, you should consider hosting it when you move your development into production.
I would recommend using ngrok or a cloudflare tunnel (both are free) during development.
Here's an example of each, the use-case is testing a webhook:
NGROK: https://www.youtube.com/watch?v=7FHbfo-wRtY
Cloudflare tunnels: https://www.youtube.com/watch?v=mMyoH4-mOiA
or use glitch.me cause ngrok webhooks is banned by facebook

Serving Multiple RASA bots on Django Backend

I’m currently trying to serve multiple bots (running different models) and to allow users to interact with it on a website. I’ve had a look at the following: http://www.rasa.com/docs/nlu/http/, http://www.rasa.com/docs/core/http/ and http://www.rasa.com/docs/nlu/python/, but I’m still having trouble figuring out how it can be done.
Some of the solutions I’ve considered are either:
Serve the bot on a HTTP server and have my website interact with the Rasa HTTP server
Create the website on Django Framework or REST API, and run Rasa Core and NLU on the backend.
What would be the best way to go about doing this? And, could anyone please briefly explain how this can be done (with multiple bot models and instances running)?
Any help would be greatly appreciated!
For anyone else searching for an answer, I ended up using Flask as the server, along with Flask-SocketIO for real time communication. The server serves an API which allows clients to communicate with it via SocketIO, determines which bot to interact with, gets the response, and sends it back to the client.

Implementing Backend IP Messaging Twilio

So I'm kind of stuck. I'm trying to implement Twilio ip messaging for our app and I'm not sure I'm finding what I need in the docs.
From what I see as examples - the only things that the backend is responsible for is the credential generation - something I have done.
Should the backend also not somehow facilitate the message sending and conversation generation?
Any useful information/documentation links/tutorial links would be much appreciated.
Twilio developer evangelist here.
The message sending and conversation generation can all be done through the client libraries, either the JavaScript or iOS (or, coming soon, Android) SDKs. That way, other than the credential generation as you pointed out, your servers don't need to be responsible for the rest of the chat application.
You can, if you choose, send messages from your own server too. Check out the documentation on the IP Messaging REST API.
If you want your server to interact with messages sent by the client libraries you can also subscribe to webhooks for IP Messaging too.
Let me know if this helps at all.

Push Notification in DRF

What should be exact and most appropriate method to implement push notifications in django rest framework. DRF documentation doesn't explain it well.
Help me out with this one
Django REST framework is for creating API in django using built in django functionalities to retrieve request and serve response.
Django by itself doesn't support any protocol that will allow push notifications to be sent to client, so DRF also won't do that.
To create push notifications you have to use websockets, there are some third-party packages adding support of websockets to django. One of them is django-websocket-redis
If you are looking for push notification on the web (using web socket), you can try to use Firebase Cloud messaging (FCM, Firebase is free with certain usage threshold). What you need is adding code to your django server to request Firebase to send notifications.
If you are looking for push notifications on mobile devices, django-push-notifications package looks good, it even provide support for DRF to keep track of devices. On Android, this will also use FCM as well.
django-push-notifications is the one you are looking for. It is simple and can be implemented with few lines of code. It can be used for all android, iOS and web push notifications.
If you intend to use WebSocket to implement your own notification, you can check out channels
My Personal Favourite for this Purpose is: Django Notification! And Django Pushy!
Other Packages: django-push-notifications Django Activity Stream
Try using the django-instapush package. It is easily available to install via pip. This support all sql databases and also mongoDB via mongoengine to store device information. It has built-in models that can be used to store device information so this will work out of the box. Here is a little tutorial on sending django push notifications using django instapush.
You can Also use:
https://pypi.org/project/django-sns-mobile-push-notification/
You can also try with some other push providers. Infobip Push has some new things, for example you can track users by their locations and send push whenever they are apporaching some areas
If you project DRF was structured without asynchronous process in mind. You can try out django channels rest framework. you can easily pass asynch classes to you viewsets and make your endpoints behave like an asynchronous porcess.

Sockjs - Send message to sockjs-tornado in Python code

I use https://github.com/mrjoes/sockjs-tornado for a Django app. I can send messages from javascript console very easy. But I want to create a signal in Django and send json string once the signal is active.
Could anyone give me a way to send a certain message in Python to sockjs-tornado socket server?
There are few options how to handle it:
Create simple REST API in your Tornado server and post your updates from Django using this API;
Use Redis. Tornado can subscribe to the update key and Django can publish updates to this key when something happens;
Use ZeroMQ (AMQP, etc) to send updates from the Django to the Tornado backend (variation of the 1 and 2).
In most of the cases, it is either first or second option. Some people prefer using 3rd option though.
I've wrote djazator, simple and easy to use django plugin. It uses zeromq for delivering messages from django to sockjs-tornado. Additionally, it can send messages to subset of authenticated django users.
I just put this up https://github.com/amagee/sockjs-client for talking directly to a SockJS server from Python (using xhr streaming).

Categories

Resources