I am developing a web app that is used for professional service professionals (accountants) to create shared workspaces (portals) for each client. These workspaces need a real-time Slack-like conversation across accountant and client -- and a key requirement is to be able to search the message history. I've looked at PubNub ChatEngine, Twilio, TalkJS, Applozic, Sendbird etc. but can't seem to find even one with this Search capability. Any suggestions?
With PubNub ChatEngine, you can use JavaScript to get past messages in a particular chat. You can write a few lines of JavaScript to filter the messages that are returned. For your use case, you would filter for your search input.
The documentation for this feature is here.
chat.search({
event: 'message',
sender: ChatEngine.me, // You can filter on a specific sender
limit: 20, // You can make a limit for the number of messages to recall and search through
start: "14375189629170609", // Optional beginning time token of messages to search through
end: "14375189629999999"
}).on('message', (event) => {
// Filter messages based on search input
}).on('$.search.finish', () => {
console.log('we have all our results!')
});
Related
I would like to know the total number of users currently in the same channel. This is a crucial information I believe.
Scenario
Caller initiates call by joining the channel -> A push goes to receiver -> Caller decides to leave call/channel before receiver joins. When the receiver reacts to push and joins the channel, sees no one in that channel. If I had a way to tell the receiver that there's no one in that channel at the moment then the receiver could be notified with dialog or some sort.
Note: without using the RTM library. Can this be done with RTC only?
You can use the RESTful API to get a list of users in the channel: https://docs.agora.io/en/Agora%20Platform/dashboard_restful_communication?platform=All%20Platforms#gets-the-user-list-in-a-channel-get
You can also implement the Agora RTM SDK together with Agora RTC SDK and implement the logic for users to join the same channel as using Agora RTC SDK. And call getMembers method to get a list of users in the RTM channel.
Here is the API document for getMembers method: https://docs.agora.io/en/Real-time-Messaging/API%20Reference/RTM_java/classio_1_1agora_1_1rtm_1_1_rtm_channel.html#a567aca5f866cf71c3b679ae09b4bf626
Here is a quick start guide for the RTM SDK: https://docs.agora.io/en/Real-time-Messaging/messaging_android?platform=Android
While using agora rtm for messaging,We can use getMembers() functionality which is provided by agora to get the active people in a channel in agora.I am defining it using javascript below for reference.
In javascript,Define a function GetMembers()-->
name='The channel Name of your channel';
function GetMembers(name)
{
rtm.channels[name].channel.getMembers().then((memberNames)=>{
/* memberNames contains an array of the names of the members*/
})
}
Call the GetMembers() function wherever it is required to get the names of the active members.
You can get the list of joined members using getMembers method of agora rtm. Remember it also gives your own id if you are logged in. This method return array.
GetChannelMembersList()
{
channel.getMembers().then(async (memberNames)=>{
console.log(memberNames, 'memberNames');
for (let index = 0; index < memberNames.length; index++) {
const user = await rtm.client.getUserAttributes(memberNames[index].toString());
console.log(user, 'user'); // To find more details of joined user
}
})
}
I want to make a unified "inbox" for messages from across multiple platforms, some of them are widely supported by all mejor chatbot services, like Facebook Messenger, others are more obscure like WhatsApp, but others are plain unsupported (like Steam Web Chat).
I've encountered several solutions that have some sort of "one-click" integration for the most popular messengers, but I can't find one that will let you integrate third-party messengers (which ideally have an API to read/send messages at the very least) into a chatbot-like service. Is there such a thing out there?
PS: I don't really care about fancy AI conversational support, I'd just like to receive all messages into, say, one webhook I can then act on, and also be able to reply to them.
API.ai doesn't have an 'integration pooling' architecture, it treats each platform as a separate integration or conversation. Given that, you'll have to build your own server side message pooling solution which plugs into all your 3rd party APIs, and then pools/queues messages across all streams before passing to API.ai, and with some messageID/tracking system on your server side solution to remember which 3rd party API to respond to with API.ai response. Something like this as an aggregate/pooling function should work:
var queue = [];
var queueProcessing = false;
function queueRequest(request) {
queue.push(request);
if (queueProcessing) {
return;
}
queueProcessing = true;
processQueue();
}
function processQueue() {
if (queue.length == 0) {
queueProcessing = false;
return;
}
var currentRequest = queue.shift();
//Send to API.ai
request(currentRequest, function(error, response, body) {
if (error || response.body.error) {
console.log("Error sending messages!");
}
processQueue();
});
}
What I would do is have a Node.js backend.
Direct every messaging integration to it and then direct that to API.AI.
So the flow would be like this:
There is a service called Message.io which does I believe what you want. They support the widest range of platforms.
Message.io sits between your bot and the messaging platforms, you receive messages in a standardized way from Message.io, and when sending messages out to users, it converts it to the appropriate format for the platform you're responding to.
We're building a web application using the Skype Web SDK (https://msdn.microsoft.com/en-us/skype/websdk/docs/skypewebsdk). We use both the audio and the IM capability to get connected to other parties.
Currently we're facing the following problem: If our application is in a conversation with another party (e. g. with a Skype for Business desktop client) and the user leaves or reloads the page, the other party doesn't get notified about the left user.
For audio conversations the result is the following: The other party is still in the call and the only indication of the leaving is that the other party can't hear anything.
For IM conversations the result is the following: If the other party sends an IM in this conversation it gets the notification that the message couldn't be delivered.
We've tried to leave the conversation before the unload of the page using the onbeforeunload event. The callback is executed both in IE 11 and Chrome, but only in Chrome the user actually leaves the conversation (tested with IM conversation since audio/video is not supported in Chrome).
window.onbeforeunload = function() {
// conversation is the conversation we're currently in
conversation.leave().then(function () {
client.conversationsManager.conversations.remove(conversation);
});
};
Since we rely on the audio capability we're not able to simply switch to Chrome only. Is there any way to ensure that the conversations are cleaned up on page reload/leave in Internet Explorer?
The problem with what you are trying to do is that the (on)beforeunload event does not wait around for asynchronous methods to complete so you are not guaranteed that leave() will execute nor the inner action to remove the conversation from the conversationsManager. I would suggest an approach similar to the following question - onbeforeunload confirmation screen customization or beforeunload
What you want to do is put the user into a state where the need to interact with a dialog which may (but also not guaranteed) give enough cycles to leave the conversation. In your case it might look something like the following:
window.onbeforeunload = function(e) {
// track if a conversation is live
if (_inActiveConversation) {
// conversation is the conversation we're currently in
conversation.leave().then(function () {
client.conversationsManager.conversations.remove(conversation);
});
var msg = 'Cleaning up active conversations...';
e.returnValue = msg;
return msg;
}
};
What you should also understand is that eventually the server side will remove that user from the conversation because the application is no longer processing incoming events. So the above is a best effort to clean up resources that will eventually be reclaimed.
You could also try to issuing a signOut request on the signInManager as that should allow the server to clean up resources related to that application on the server side.
window.onbeforeunload = function() {
...
_client.signInManager.signOut();
...
};
I've been tasked with setting up a bot to work with Yammer, as we are investigating using Yammer as an office communication tool.
Bots are essential to workflow, so they can notify users of important real-time events and can respond immediately to queries about system states even when not in the office without the need of complicated remote-desktop systems.
I've looked into Hubot, which has a Yammer adapter using a deprecated real-time API. However, this only reacts to posts made to public groups, and does not respond to private messages.
How would I start implementing something (which APIs to look at) to receive and send private messages in real-time? I feel this surely must be possible for a communication platform like Yammer (otherwise this defeats the point?), but I cannot find anything in the API documentation.
Thank you for your time.
Few changes in the hubot-yammer and yammer modules would make the adapters work with private groups as well.
Here is what I have done to make it work with private groups.
main.js:
I have modified the main.js of yammer module to pass the group id up front and modified it to call the messagesInGroup API of yammer to listen to private group messages.
RealTime.prototype.messages = function (g_id,cb) {
this.yam.messagesInGroup(g_id,function (e, body) {
Yammer.coffee:
Further modified Yammer.coffee script to call the yammer module with private group id.
class YammerRealtime extends EventEmitter under options
if options.access_token?
#g_id = options.g_id
## Yammer API call methods
listen: (callback) ->
#yammer.realtime.messages #g_id,(err, data) ->
With above changes hubot-yammer listens to private groups and responds back.
I would like to use PubNub with Parse for a chat module. Could somebody explain me how can i send messages with text and images via PubNub to a user (only one-to-one)? I wanna use the PFUser usernames as the id of a user's private channel.
I've found this code in the PubNub help docs, but i've never seen code like this in objective-c. Where/how should i use this line?
curl https://pubsub.pubnub.com/publish/<PUB-KEY>/<SUB-KEY>/0/<CHANNEL-NAME>/0/%22Hellooooooo%22
It's also unclear for me that where should i store the messages? In Parse or can i store them only at PubNub? I'm not sure that the second variation is possible, because i didn't see any data storage at PubNub. Or for example i'm sending only the url's of the PFObjects that i store at Parse?
Parse + PubNub Publish Messages
You can publish messages inside of parse cloud to your mobile users to create chat experiences easily. If you want to send the messages directly from within Parse Cloud use the following code to send a message to a user:
Publish PubNub Message on Parse Cloud
Parse.Cloud.httpRequest({
url: 'https://pubsub.pubnub.com/publish/<PUB-KEY>/<SUB-KEY>/0/<USER-CHANNEL-NAME>/0/%22Hellooooooo!%22',
// successful HTTP status code
success: function(httpResponse) {
console.log(httpResponse.text);
},
// unsuccessful HTTP status code
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
You don't necessarily need to use Parse this way. You can instead send messages directly between users to each user's channel name. Sally has "channel-sally", and Bill has "channel-bill". You can publish and subscribe directly form your Objective-C App Code. Bill will subscribe to his own channel and a Sally to her channel.
Bob's App
// Define a channel
PNChannel *myChannel = [PNChannel channelWithName:#"channel-bob"];
PNChannel *friendChannel = [PNChannel channelWithName:#"channel-sally"];
// Receive Messages Sent to Me!
[PubNub subscribeOnChannel:myChannel];
// Send a Message to Sally
[PubNub sendMessage:#"Hello from PubNub iOS!" toChannel:friendChannel];
//(In AppDelegate.m, define didReceiveMessage delegate method:)
- (void)pubnubClient:(PubNub *)client didReceiveMessage:(PNMessage *)message {
NSLog(#"Received: %#", message.message);
}
Bob can receive messages on his own channel and he can send messages to Sally or any other of his friends.