Answer the question
In order to leave comments, you need to log in
How to attach a question-answer form to the site in the form of an online chat?
Hello!
I attach the functionality of the "reference" to the project - visitors ask a question and immediately (within a few minutes, if the operator is online) receive an answer. I made it up like this:
I am an amateur programmer, I use php, sql and js on the project. I don’t understand modern js frameworks (I heard something about socket.io and node.js). Please tell me which way to dig in order to implement this functionality as simply and quickly as possible:
1. When a visitor asks a question, a notification arrives somewhere (messenger, mail)
2. The site operator answers the question (from the admin panel, messenger)
3. The question and answer are stored in database
4. The visitor immediately, without reloading the page, receives the answer.
A cool example that works according to this scheme is here:sevastopol.nashaspravka.ru
Visitors ask a question through the form, and site operators immediately answer it within a few minutes. And, most importantly, these questions are stored in the site database and the history of questions and answers is stored.
Thank you.
Answer the question
In order to leave comments, you need to log in
To work with web sockets, you need a comet server. But since you do not want to raise it yourself, you can use the ready-made saas comet server . It will provide fast message delivery and relieve you of the problems of maintaining a server infrastructure. And at the same time, all correspondence can be stored with you.
This is something between writing everything from scratch or using a finished product.
Such modules are now fashionable to buy from third-party companies. There are a lot of offers on the market.
But if you still want to do it yourself, then AJAX is enough for such a "chat", no web sockets are needed, since there is a big lag between the user's question and the operator's answer. It is enough to request the server once every 30 seconds for a timer response and that's it.
The easiest way to do this with Ajax is to use jQuery and its Ajax API.
The Ajax solution doesn't make sense for a bunch of reasons, from user experience to server load.
If you want to cut yourself - then actually node.js + socket.io. There are plenty of examples socket.io/docs
I would not cut it myself and take some www.jivosite.ru
Denis Ineshin
no websockets needed as there is a big lag between the user's question and the operator's response" does not existThere is no lag. Should not exist. If the operators are not trained to answer in 10-15 seconds maximum , the introduction of this thing will be more negative than good.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question