RabbitMQ send messages to users on website - javascript

I am trying to use RabbitMQ to send messages to users on a website. While I know how to communicate between different scripts I can't find anything about how I can get a new user to recieve messages.
Let's take chapter 1 of the tutorial as example: https://www.rabbitmq.com/tutorials/tutorial-one-python.html
How would I be able to send "Hello World" to a user on my website and be displayed in the console? Would it even be possible using python?

Try using the RabbitMQ Web-STOMP plugin: https://www.rabbitmq.com/web-stomp.html

You wouldn't use RabbitMQ for that. It's for communication between different services in your back end, not for sending messages between arbitrary users on your front end.

Related

How to integrate a chatbot webhook with a web-based chat window?

I want to develop a web-based chat conversation. I have a Dialogflow webhook that is up and running and that can be easily integrated with, say, facebook messenger or whatsapp, thanks to the functionalities of Dialogflow itself.
Now, say I want to have a web-based chat plugin that I want to interact with said Dialogflow webhook. How does that work, in terms of setup? There are things I know I need, I would like your help to identify things that are still missing and to help me put them all together (conceptually).
I need something to make the chat conversation look pretty; I was hoping there would be some chat plugin online to style messages but the things I could find are always more complicated than that and have functionalities for you to set messages for the plugin to send automatically and things like that.
I need something that is triggered when the user sends a message; when the user sends a message I need to send it to Dialogflow in order to have it fulfilled. Can this be done directly from JS? Or do I have to send some request to my server, which will then call Dialogflow and return the user message?
Is this all I need? I am sorry if this question is too confusing or broad, I'll be glad to give further clarifications as needed.
I think you need this.
https://cloud.google.com/dialogflow/docs/quick/api#detect-intent-text-nodejs
When you use the API for interactions, your service interacts directly with the end-user. For each conversational turn, your service sends end-user expressions to Dialogflow by calling the detectIntent or streamingDetectIntent method of the Sessions type. Dialogflow responds with information about the matched intent, the action, the parameters, and the response defined for the intent. Your service performs actions as needed (for example, database queries or external API calls) and sends a message to the end-user.
It just API interaction with your chat client, you can design the way you want.

Sending messages to google cloud pubsub topic from browser without authentication

I want to write a simple javascript plugin that can send pubsub messages from the browser. But because these clients may not be (or may not want to) log in, I would like to have the plugin be able to send pubsub message unauthenticated. Is that possible? If not, what would be the best way to achieve this.
The specific use case here is: writing an web analytics plugin that can track something like page load and other events.
Sending pub/sub messages would require one to be authenticated against the project where the topic was created. Your client logging into a Google account would not be relevant unless you planned to give every user of the page access to your project.
What you probably want to do is have a service running that is authenticated to publish messages. Requests from the browser would be sent unauthenticated to this service and then you could publish a message (after some verification that it is a legitimate message, I expect) into Google Cloud Pub/Sub.

How to include send message and inbox option in a Node.js web application

I want to add a send message and inbox option in my node.js application. Basically the website is all about posting jobs in the forum, where three types of people can search and post jobs according to their profiles. Three of them are freelancers, mentors and clients.
So in order to them to communicate with each other, is there any way i can include a chat option in each of their profiles, so that they can send messages to each other.
I have also checked the option of Socket io for chat application, but i am little confused that whether is it a right solution according to my requirement or not.
socket.io will allow for realtime chat communication like gmail's 'gchat',
so socket.io would be a relevant solution to your problem.

Direct Message to online users in MeteorJS

In a chat application, I want to be able to send messages to two users directly if there are online. I'm using mizzao:user-status to detect if they are online or not. Let's imagine 2 users Tom and Sam. So both are online and using the application. Now when Tom sends a mesaage to Sam and vice-versa, I want to send the message directly to Sam without first storing it in MongoDB through Web Sockets. Meteor Streams seemed like a viable option, but here's the problem. Let's say 1000 people are using the app all at once. Now some people can send only their friends messages. How do I ensure security so Sam can't edit some source files and read everyone's messages going through the wire.
Thanks.
When I was doing my chat app I didn't use any streams, since Meteor is reactive I just stored all messages in a Collection, and find() was returning data, no packages were needed.
If I wanted to send data to users, I simply fetch() users who are online(with mizzao:user-status aswell), and then sent message to all of them using .forEach

Implementing web chat, how do I get typing status?

Can someone illustrate how I can get typing status of the other party with JavaScript?
UPDATE
Can someone recommend a one-to-one open source chatting application, preferably written in PHP? I only found open source chatting rooms which are for chatting among all onliners, but I just need a one-to-one chatting.
Here are a list of PHP-based open-source instant messaging software.
Some of those might be relevant for you.
For example, if you had an text area #chat then you could use this code to attach the event:
document.getElementById('chat').addEventListener('keydown', FUNCTION HERE, false);
See http streaming and some ready solutions here: http://ajaxpatterns.org/HTTP_Streaming
this is how google talk does it. And there are ready php or c++ solutions
It was quie a discovery for me!
This is an update to reflect the significant change in the OP's question:
Google Chat and Facebook both use XMPP(jabber) servers, as do most companies I know of that have internal instant messaging.
The nice part about XMPP is that you get all of the "is typing" and other presence-based information without having to roll-your-own in javascript (bear in mind, you will still need to use javascript to pass XMPP requests back to the server, but XMPP has most of the features you'd need already built in).
Check out OpenFire. It's a great XMPP server, totally open source, and they have a web-based version of their Spark client that is pretty nice.
Or you could get a PHP library for XMPP (there are a few). But you'd still need to have the XMPP server running in the background for PHP to work with.
Here's a list of XMPP libraries for PHP from XMPP.org:
Eiffel
JAXL
Lightr
Missus
xmpphp
Or, if you want to keep things mostly browser-side, they also have a list of libraries for javascript:
dojox.xmpp
js.io
JSJaC
strophe.js
xmpp4gwt
xmpp4js
I made a small chat application a while ago, and the only way to do it is to frequently check for new entries in the chat database and fetch anything newer than the last displayed message. At the same time as all that, you can check to see if the user's input is empty. If it is, do nothing. If it isn't, enter a status code into the database beside that user's name. If anyone has that status in the database when you're fetching information about new messages and who is online, you should display the 'user is typing' message. I hope that makes sense...let me know if it isn't.
For User1: If you save the chat message on each key-press to the database, with a status: sent=false and update the last updated date.
For User2: you could pole periodically for the presence of a message where sent=false and use the last updated to update user is typing message. if the lastupdated date is more than a say ten seconds you could remove the message as that person may have stopped typing. This will allow User2 to see User1 typing, stopping and continueing again.
Ideally polling for this information will be part of an existing call to the database to reduce additional overhead.

Categories

Resources