How To Send Notifications To A Specific User Group / Role Only using Socket.io? - node.js

I am working on a project which I want to implement a feature where after an action happens, I want to notify all online administrators on the web app and show them a message that an action happened.
I have a few questions:
How can I identify which user is online and has an admin role? I am looking for some ideas around "show all online users" list
Should I put these admins into a room where I can broadcast the notification only to that room?
How can I get all users who are online and associate their socket ID with the ID / Username in the database?
I will also need the online status to be shown in a table so I can know if UserOne and John are online at the moment.
How can I keep the online / offline status? Do I have to keep the status somewhere outside of the database?
I am using Laravel v5.1, NodeJS v5.0, Socket.io v1.3 and Redis to play around with the notifications.
Does anyone have any idea how can I deal with this problem? I am not really looking for any code specific stuff, I am just curious about the theory behind the idea and how it will work.
Thanks!

Related

Checkout and buy confirmation with Snipcart and Strapi

It's probably a noob question, but I've been searching for a while and haven't been able to find the answer so far.
I'm currently building a webpage with strapi and snipcart. I've got a user login system on strapi, users can buy courses and do the checkout process with snipcart without registering a user account there.
After buying the online course, I need to give the user access to the course in strapi. I just can't figure out how I can send a request from snipcart to strapi to confirm that a user has bought the course and therefore is allowed to view it in whilst being logged in.
Since snipcart and strapi are not connected I'm trying to figure out how I can send a request from snipcart to strapi. I've been stumbling across webhooks, but I'm not sure if this is what I'm supposed to be using yet.
Any help is appreciated.
So I figured it out, but didn't have time to reply yet.
After an item is bought, the snipcart sdk can send a cart.confirmed event where you can listen to.
After listening to the event you can send the snipcart information to your strapi backend to save it. Here you can for example have a boolean which gets updated if the user has bought a course/item.
https://docs.snipcart.com/v3/sdk/events#cartconfirmed

Microsoft Bot transparent authentication

I just started exploring Bot Framework and I case that I wasn't able to find an answer for came in my head.
I want my bot to say something like: "Hi " when the user type hi, hello etc, but at the same time I don't want to prompt the user to sign-in again, because he already did it when accessing the page. How to achieve that when I insert the web chat as iframe?
The user is authenticated using AAD. I found this article, but i wasn't able to make it working, idk why.
Thanks in advance for you answers.
For your scenario, you can use the BackChannel mechanism. With this, you can pass messages from/to the WebChat Control from/to your page. And more on your question, maybe you can pass some user data to the WebChat when user is logged.

How to implement a chatbot to human executive switch using Microsoft Bot Framework?

The exact point being, that I've created a bot that can take inputs from users in free form text and return relevant web links. Now the problem being, that in case the bot is not able to understand the user query, the control of the conversation has to be passed on to the human executive.
I've researched for over 2 days but could not find any such implementations. The closest I came was third party applications like ChatFuel, letsclap.io provide such a provision. So, there should be a way only that I am not able to find such a thing.
Any help on this would be appreciated.
one possible way is you can make a bridge, idea is as follow:
user send something that the bot cannot reply (conv-1)
make a new conversation with your human executive (conv-2)
forward user message to conv-2
human executive replied to the bot (conv-2)
capture the message and forward back to (conv-1)
See this link on how to start a new conversation:
https://docs.botframework.com/en-us/csharp/builder/sdkreference/routing.html#sendtoconversation
Hope it helps,
Maybe you can create some APIs in a WebApplication that will be used by your bot.
If the LUIS Intent "None" is called, you make a call to that API and start a new conversation with a human.
You can use this same process to manage all conversations in a WebApplication Chat Control

Node.js Trade Notification for Steambot

I'm not a coder, but I'm asking on behalf of my web developer who isn't fluent with english, for everyone's expertise.
I'm trying to achieve a real time trade notification on my website.
I have the node.js bot working for all trading purpose already and its interacting with the web with socket.io. Inventory is working. But I do want to add an addtional functionality when the trade offer is send, a notification will also in real time event sent to user on my website at the same time my bot sent a trade offer to the user in steam.
Below is a screenshot example,
https://gyazo.com/ec41e836605f2284f834dd7606693e22
Really appreciate if anyone could help me out.
This all depends on the way you handle your data.
If you are making it so the bot sends a trade offer to the user then when you call your trade offer add in a
socket.emit('tradeOfferSent', {
});
to that user which can be picked up on the client side by
socket.on('tradeOfferSent',function(data) {
});
conversely if you are making your users send trade offers to the bot you can use on 'newOffer' from steam-tradeoffer-manager to emit the data as above.
Inside the on.socket('',function(){}); you are able to add anything you want as an notification. Such as using sweetalerts.

Is mediator-js realtime? How can I add subscribers to the channels?

I am fairly new at this. I am using Nodejs and Express linked to a mySQL database to build an application and now I need some library that allows that realtime messages are sent to the right users.
I have already tried socket.io but it was a little complicated for me to understand the documentation, so I searched for some other alternatives.
I found Mediator.js and I was trying to implement it in my server but now I am getting to the conclusion that I don't know how to make it work in real time.
The website has an Admin and several normal users;
The users can belong to groups (one, many or none) that the admin assigns.
The Admin has to be able to send a string to the users that belong to a specific group if they are online - realtime.
Is this possible to implement with mediator-js? Admin sends string to server and then server broadcasts to the members of the group that are online in realtime?
Or do I really have to use socket.io?
Thanks for your help in advance.

Resources