I'm currently working on a NodeJS powered Messenger Chatbot, using Wit.ai and Firebase, hosted on Heroku. I've followed an udemy course to learn the basics about chatbots and I've made a decent chatbot imo.
But, as I'm adding new features, I don't really know how to correctly structure and organize my project. To be honest, I've currently have one big index.js file, of about 1 000 lines, because in the middle there is a giant Switch Case structure managing all of the intents a user can possibly have.
I'm also making nodejs modules with "exports.function" but it seems it's an old way to do and it doesn't solve my switch case problem.
Do you any suggestions to solve my structure issue ?
I've found this post suggesting some structures but I don't know if it can really fit a Chatbot project.
Thanks for you time, have a nice day.
personally, i suggest to try out node-red as it is easier to visualise if you have many APIs you want to connect to.
I've currently have one big index.js file, of about 1 000 lines, because in the middle there is a giant Switch Case structure managing all of the intents a user can possibly have
This is clearly to avoid. In these conditions the code is hardly readable and untestable. I wrote an article on how to structure a Node webhook for a chatbot. Jump to the section Chatbot Webhook to have an example on the implementation. It is for a Dialogflow chatbot but you won't be lost as Wit.ai and Dialogflow have many similarities.
Related
I am new to React. I created a simple login form and sign up form.
I am a little confused about using a backend. I've Googled it (lol) and I've seen a large variety of answers from using AWS to creating another project with NodeJS/Express.
For a beginner, what is the best approach? What confuses me is that I am handling all the routing in my React app. The tutorials that I've seen appear to handle routing in the NodeJS/Express portion.
Like Chris mentioned your question is to broad to answer, but I'll try to propose some general directions which may help you to pursue building a back-end.
There is not really a best approach. I suggest you look into several courses and tutorials on what web technologies suits best for the type of application you want to build. Start first by selecting which framework would provide the most productive and scale-able workflow for you. This is depended on various factors of your envisioned application and your current skill-set. Then follow along tutorials and read documentation of each separate technology first to get a good understanding of each building block. When grasping how everything functions individually, looked in complete full stack tutorials to see how everything works together and how you connect your front-end to your back-end.
I chose for a Nodejs RESTfull API myself using the MERN stack (MongoDB, Express, Reactjs and Nodejs), but you can also look into python (django, flask) or PHP back-ends as well.
Some good Youtubers to get you started:
https://www.youtube.com/academind
https://www.youtube.com/traversymedia
They provide many up to date tutorials for different web-technologies so you can make an informed decision yourself of what you want to adapt to.
Keep in mind there is a lot to work with when you just getting started, but at some point things will become familiar after using it over and over again and it becomes less overwhelming.
I need to write own video hosting with player on client side.
My required approaches:
The user can upload video to hosting
The user can watch any video from hosting
I don't ask to write me solution, I am asking for help where should I start from to lean about it? Which technologies or frameworks should I learn for my task to realize it using python?
P.S. Each detail will be very useful, especially some links to articles because I couldn't find by myself not knowing accurately what do I need to search.
Added
Now, I think to store videos in the file system directly and use postgresql to store additional information about videos and users. Of course, large services use Hadoop, BigTable and etc but for my task so solution will be enough I think.
When the user uploaded a new video, my server saves it into a temporary directory and puts in the processing queue. Small programs takes new videos one by one, generates thumbnails and decrease a quality of videos and moves it to the base storage. Is it a good idea?
But I still can't get how make a video streaming
Ok So I dont want to encourage the behavior of people thinking SO is a codewriting service, But this is a truly legitimate answer. So first of all, you want to choose a language. Currently I'd recommend the use of javascript and Node.js (Java needs to die). However, IDK Node as well as I know Python. Python is an all purpose language yadda yadda yadda blah blah blah. Whats important in this case is your framework of choice (or library). The libraries that allow you to make websites in python (or make it easier to do so) are very interesting. There are several but my favorite is Python Flask. Python flask is actually very similar to Node.js + Express.js. Use this link to get started. Take a few days to learn the insides of this framework. VERY MODULAR, VERY POWERFUL. Using basing logic and database knowledge, one can easily accomplish a simple file upload and authentication-using, web service. However I Know of 2 really good guides that will help you with the streaming of the videos. I mean yes, You don't really need to know this. You could potentially load the requested video using a <video> tag, but streaming is a much MUCH
more favorable solution. Take some time to learn about video streaming and compression, and after you think about it, check out these links: AUDIO STREAMING GIST and MIGUEL GRINBERG FLASK VIDEO STREAMING BLOG POST
Good luck with flask and
Pro tip: learn about http(s) and the get and post methods
You would never imagine how many times I struggled with a bad request error or a method not allowed because I didn't do my research
I'm still a newbie in firebase so i might not have the right understanding of this excellent service.
I'm building a blogging mobile app in a client-server architecture in which most if not all the logic are done server-side. all the client does is request and display the result. the client-server communication will be in REST API. and post-processing data then will be pushed to firebase.
keep in mind that this is all still a work in progress and i still don't have an actual working setup yet.
my questions are:
1. is this possible?
2. is this good practice?
a 2nd architecture I'm thinking is to have the client talks with firebase directly and have the nodejs process any events coming from firebase.
same 2 questions as above3. which is better?
mind you i'm also a newbie in nodejs and just start to learn nodejs for this purpose.
Many Thanks in Advance
I am writing a nodejs / express / mongodb based web application and all is working great.
What I've made for learning purposes is a twitter clone.
People can tweet whatever they want and it will show up on their profile and anyone who follows them stream.
On my home page it shows everyone who you are followings posts.
I want this stream to automatically update when someone they are following posts something new.
So they can just sit their on the home page and see all new posts come in in real time.
I've worked with Socket.IO in the past and loved it for it's awesome simplicity of use.
But is Socket.IO an appropriate use for this sort of situation?
Are their better options I can use, perhaps going with a simpler approach of AJAX polling would be more efficient for scalability?
So basically what is the best to use for an application like this?
I need:
Realtime updates to the client
Scalability and effeciency
Thanks!
You have multiple option
My firstoption RacerJS
and Socket.IO
Get data from mongodb and send through racerjs or socket.io
RacerJS is synchronization model built on top of ShareJS, which has underlying technique called Operational Transformation, this is used to do collaborative work on the same data in real-time (like Google docs) I guess it does not really apply to your case or its not the case where it should be used. Because ShareJS does a lot of work to keep clients able to edit at the same time on the same data. This is not the case with Activity streams like your case.
A good option would be Meteor
I'm Developing (yet another) Node,js + Express + Socket.IO Facebook/like Instant Messaging app.
The server-side is mostly complete, but I was looking for a proper way to store and retrieve conversations and I thought I could give MongoDB a try.
I've never worked before with noSQL databases before, so I would like some suggestions on how to deal, mainly, with the writing the proper way.
I was thinking in creating entries containing the user chatting and the chatlines with a timestamp, something simple.
Any thoughts?
Though this does not exactly address the app you are looking to build, 10gen (to company that supports mongodb) has released a video of a presentation walking through the creation of an IRC chat server. This is a very long and very extensive presentation and should cover most of the material that will be relevant for you in building your app. Definitely seems to me like the best resource for you to get started with.
http://www.10gen.com/presentations/mongonyc-2012-building-mongodb-power-chat-server
Hope this helps!