How to put my DialogFlow chatbot with python on line? - python

I am developing a chatbot using DialogFlow, as my natural language processing handler, and Python as my client.
My application aims to talk with a human in a python environment (I am currently using a Jupyter Notebook), send the request to DialogFlow, get the response, then calculate the data using some python libraries and show the results to the user.
All the process described above is already working.
Now I must to find a way that lets the people uses my chatbot on line.
Here is my problem, I don't know how to model this.
I think I should put my chatbot in a webpage and make it communicate with my python application stored in a server.
Did anybody make something similar?

Given your current architecture, you'll have to do the following:
Write a client for your chatbot in HTML and JavaScript
Write a server in Python that contains your application logic and makes the API calls to Dialogflow
This is a pretty normal architecture for a web application. Given that you're using Python, you might find Flask or Django helpful.
There should be plenty of samples out there that can help you figure out what to do; I just found this blog post that demonstrates how to build a simple chat client/server with Flask and websockets.
If you're willing to change your architecture so that the user interacts directly with Dialogflow, and all of your application logic lives in the Dialogflow fulfillment webhook, you can make use of Dialogflow's Web Demo integration that provides a pre-built chat widget you can embed into an HTML page.

Related

How to communicate data from ReactJS and Python?

I'm building an app in which I need to communicate data from and to ReactJS and Python. It needs to go both ways - but I'm more concerned about the React part right now. At first I considered JSON, but couldn't find any resources/ libraries to update JSON files, and people said I should stay away from that. Other than literally creating a text file with data in it, what are my options? The application has to do with getting stock data from a python API, doing calculations on it, and sending the data to ReactJS to render on a webpage. I also need ReactJS to send account data back to Python where we do our MySQL. Any suggestions?
Since the ReactJS app is a front-end application, your only real choice to ensure security is exposing an API on the python app which the ReactJS app talks to (via Websockets for example since you're mentioning a bidirectional communication). Maybe take a look at something like Flask with the flask-socketio package.

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.

How to create a Python API and use it with React Native?

I'm learning about basic back-end and server mechanics and how to connect it with the front end of an app. More specifically, I want to create a React Native app and connect it to a database using Python(simply because Python is easy to write and fast). From my research I've determined I'll need to make an API that communicates via HTTP with the server, then use the API with React Native. I'm still confused as to how the API works and how I can integrate it into my React Native front-end, or any front-end that's not Python-based for that matter.
I think you have to follow some online tutorial
And from my experiences, I think Flask is good choice for such case.
This is basic flask tutorial provided by tutorialspoint.com
You have to create a flask proxy, generate JSON endpoints then use fetch or axios to display this data in your react native app. You also have to be more specific next time.

appengine endpoints tictactoe python on iOS example was written with java backend, how to make it work with python?

The tictactoe example from google endpoints have versions for both java and python. These can be used with javascript, android, and iOS clients.
I want to use python endpoint with iOS client, but the source code for the iOS client found on github was written for java backend. What do I need to change for it to work with python endpoint.
Python endpoint: https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-python
iOS client:https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-ios
Update:
I guess I didnt phrase my question clearly, within the python endpoint file for tictactoe. the request is routed to static/js/render.js and static/js/base.js. I was wondering how to do those things with another python file, without going through those javascripts.
I want to know: what is the 'message'(the win or lose data, and what kind of data) is send by iOS to the endpoint. And how would the endpoint find this 'message' and use the api.method to put this 'message' to ndb?
Once you have your backend ready, generating client libs for JS, Android or iOS is straightforward. Don't forget to run the same command in the terminal every time your API code changes (in order to update your client libs).
Here's a step by step guide on how to do it.

Is there any python module for sending messages between users in a web application?

I'm using pyramid to build up a web site and would like to find some modules about sending messages between users accounts in my web site. I've heard that rails has some gems for that such like https://github.com/ging/mailboxer or https://github.com/pluginaweek/has_messages .
I would like to find the python one. Can anyone recommend me some python modules?
Thanks!
You're probably best off using an existing protocol like XMPP. For Plone (a Python CMS) for example there's a complete XMPP integration with collective.xmpp.chat providing multi-user chat and Instant Messaging between authenticated users of a Plone site (demo video).
For Pyramid you'll need to do this integration yourself [1], by running a Jabber / XMPP server (such as ejabberd) and using an existing XMPP client library for Python to communicate with it. There are plenty of XMPP libraries for Python, some of them are described in the answers to this question.
Note: Don't be scared if after looking at XMPP it looks way to complex. XMPP and its extension describe a wide variety of features related to Messaging and Presence, chat is just one of them. If you don't need the other features, simply don't implement them in your webapp.
[1] Actually, there is a Pyramid project that seems to do exactly that: seshat, written by #KirkStrauser. I haven't used it myself, but it looks very promising.
No; direct communication between two individuals isn't possible in web applications because they use stateless protocols; the server does not know if the request is coming from the same person or not.
That being said, what chat applications usually do is store the communications within a database between the 2 individuals, and use AJAX to retrieve them.
There are already lots of chat application tutorials and 3rd party chat application packages online; you might want to check them out.

Categories

Resources