making a Django chatbot application interact with multiple users - python

i have a django chatbot application on web faction shard host. the idea is : the chatbot application simulate the customer service in chatting with the customers.
Basically the conversation will be exchanged through the API using GET and POST, where it first POST the input then GET calls the python file to SELECT the input form the DB and process it then update the database with the retrieved out put.Finally a GET is used to fetch the out put and display it.
so far it is working for one user at a time, what i am considering now is that i want it to chat with multiple customer at the same time an isolating each user.
Do i have to use Redis just for the chatting part, if yes how i can merge it in my project? other there are other solution out there?
i have developed it using:
python3: for the chatbot code.
Django: for the website.
Mysql: for the data base, that hold the knowledge based for the chatbot such as a table that include number of input and it correspond output.
Thank you,

There is a whole chatbot solution based on Python 3 + Django + Mongo/sqlite. Its github link is https://github.com/gunthercox/ChatterBot. Hope it can help you.
This repository also contains Django application example: https://github.com/gunthercox/ChatterBot/tree/master/examples/django_app

You can use Redis,Celery,Python RQ,Rabbit MQ as a queue for distributed tasks(chatting tasks) in your Django app. But this will increase complexity in your project. I will recommend you to Develop Python based multi client chat server.

Related

Web architecture for "sharing" API calls between users

I recently posted a question: How to dynamically create and close infinitely running Celery tasks using Django Channels . But Django channels seems to be a fairly niche area of development so I'd like to open up the question as a question about general architecture patterns.
I would ultimately like users of my application to tap into the same data streams dynamically.
I am creating a cryptocurrency application where users are accessing the same live price data.
It seems ridiculous that every user should have to request an API for the same information.
Scenario:
Multiple users are receiving BTC/USD data by API request. How can I get this data and share it between users?
This problem must have been solved countless times but I'm finding it very difficult to find the correct method for setting up a scalable solution.

Which AWS infrastructure to choose to write an automated application in python?

I have a basic background in DS with Python and I try now the first time to build an application and I need a bit advise which infrastructure to choose on AWS and how to structure the application. The code I can develop/google on my own :)
The main question is: Where/On which platform of AWS should happen Step 2. I guess I miss there some basic knowledge of applications and therefore I have problems to google the problem myself.
What should happen by the application:
On a website a user types in values in a form and this values are sended somewhere so be processed. (Already coded)
Now, this values (so far an email with the values) has to be sent somewhere to be processed. Here I do not know in which infrastructure of AWS I can write an application that can receive this values (/email) directly and process it automatically?
3./4. Automated process of values, pdf creation and sending etc.
Goal is that always when a user uses the website and sends the email, that the automated process is triggered.
Thank you for your help! :)
I am assuming that you have access to the mailbox to which user form data will be sent via email, You can then read the email data using imap module of python and extract the required information either by using regex or by some html to dict conversion module, please find below link for html to dict conversion.
How to convert an HTML table into a Python dictionary.
Having said all that I would strongly recommend you to use AWS EC2 instance to host your application, NGNIX as web server, postgress as database and most importantly Django as the webframe work, you should have the user fill the require data in form and send that form directly to the back end server which can then save it directly to your database (there is no need to send the data via email), if you have any queries please let me know.
I would suggest you use a "fanning out" architecture with something like Eventbridge or SNS topic.
When your user submits form, you publish a message to an SNS topic.
That topic can send an email, and also send the data to a backend service like lambda to save to something like DynamoDB or something like RDS MySQL.

How to connect a completed Vue.js app (frontend) to Django (backend)

I'm currently doing a school project that tasks us to create a functioning web application (with database) for our university. Our application is an intranet-based activities logging system.
During our first term, we finished our frontend via Vue.js / Vuetify. It has complete routers (and multiple pages), functioning buttons and data-tables (and fake authentication).
Now, we need to connect it to the backend. We chose python django REST API as our research found that it would be faster to implement (our deadline is in 2 weeks tops). My question is how to (or if it's possible) to connect our vue.js application to django so that it can fetch login authentication and database queries to our SQL (postgreSQL).
We were using the Vue CLI during the building of our frontend.
Thank you!
You don't have to worry about integration much. This is a simple REST API and a Frontend framework.
You can find many tutorials online for the same and set it up from scratch, but keeping your deadlines in mind. I think you should use this boilerplate to start with: https://github.com/gtalarico/django-vue-template

How to get a standalone python script to get data from my django app?

I am currently learning how to use django. I have a standalone python script that I want to communicate with my django app. However, I have no clue how to go about doing this. My django app has a login function and a database with usernames and passwords. I want my python script to talk to my app and verify the persons user name and password and also get some account info like the person's name. How do I go about doing this? I am very new to web apps and I am not really sure where to begin.
Some Clarifications: My standalone python program is so that the user can access some information about their account. I am not trying to use the script for login functionality. My django app already handles this. I am just trying to find a way to verify that they have said account.
For example: If you have a flashcards web app and you want the user to have a program locally on their computer to access their flashcards, they need to login and download the cards from the web app. So wouldn't the standalone program need to communicate with the app to get login information and access to the cards on that account somehow? That's what I am trying to accomplish.
If I understand you correctly, you're looking to have an external program communicate with your server. To do this, the server needs to expose an API (Application Interface) that communicates with the external program. That interface will receive a message and return a response.
The request will need to have two things:
identifying information for the user - usually a secret key - so that other people can't access the user's data.
a query of some sort indicating what kind of information to return.
The server will get the request, validate the user's secret key, process the query, and return the result.
It's pretty easy to do in Django. Set up a url like /api/cards and a view. Have the view process the request and return the response. Often, these days, these back and forth messages are encoded in JSON - an easy way to encapsulate and send data. Google around with the terms django, api, and json and you'll find a lot of what you need.

How to do socket programming in a django app

I have a Django web application which shows a website to display some data. So, this application consists of the html pages and views to display this data which i am storing in a SQLite DB.
At the end of the day a third party needs to connect to this web application and upload binary data over to the application. What is the best way to host this service, as an independent python web server or part of Django application or how else ?
Any suggestions would be appreciated !
If the uploading doesn't occur too often, why not just create a Django POST/PUT view for the job that simply accepts the file over HTTP? With the information you've provided, I cannot see why this simple solution wouldn't be up to the task.

Categories