I try to build a support center app with twilio or pubnub. it's fairly simple:
user starts a public chat
someone from the support team accepts -> public chat turns private
when supporter has anwsered the chat request, chat turns public again
The app would be build with titanium appcelerator for the user and angular for the support team.
Twilio
Since twilio doesn't provide a native titanium sdk, I looked into its programmable chat rest api - but in my opinion it lacks one important feature: when i open up a channel, I can't modify the create_by property. It is system by default. All I can do is, get all the channels at once for all users.
So I can't get all the channels one user is subscribed to. I would have to manage all channels by myself. Is that right so far?
PubNub
PubNub on the other hand I don't get. They encourage you to have not more than two channels per connection. But one user has to be able to open as many tickets as he likes. So how can i organize it? Also, their approach to private chats is to have a private chat-name. but then I don't know how I could switch between private and public without loosing the history. Can I move messages from public to private channel? One way I could think of is having a unique uuid assigned to each conversation thread. That way I could group messages into threads, regardless of the channel. Would that be a valid approach?
Related
I'm currently upgrading my implementation that uses Twilio IPM to use the new GA release twilio-chat after previously using the twilio-ip-messaging package on npm. There are some disparities between the implementations, but this hasn't really been that much of an issue so far. However it seems that there are some event behaviours that have changed and I struggle to understand why.
Prior to twilio-chat, if I had a client A connected in a browser context, any public channel creation (from another client B, or the server side) would trigger the channelAdded event from twilio. This no longer seems to happen. The new channel is visible on any subsequent getPublicChannelDescriptors call, but I do not receive the event.
Is it possible to opt-in to these events? Or in some other way configure that this should be announced to all connected clients?
I can think of a few workarounds, like a named persistent channel where new channel creation is announced, or some other 'push' mechanism for client A to then refresh its channels list, but all feels a bit dirty when there is already a push mechanism in place that used to effect the same behaviour.
Twilio developer evangelist here.
The channelAdded event for public channels was removed in the Programmable Chat SDKs because of a limitations of how many endpoints can subscribe to a single, global public channels object.
You can receive these events by webhook but you would still need a way to notify the client side of your application. Your suggestion of a persistent channel for this is a good workaround. You could even keep this channel hidden from view and send structured data in the message that would allow you to show the new channel in your interface and request more data about it via the SDK.
If a whole chat channel is too much of a hack, you could also try using Twilio Sync to synchronise a list of active channels between users.
I agree that this does seem like a bit of a hack though. It is possible that all channels will cause the channelAdded event again in the future, but I can't promise anything like that right now, so you will need to workaround it.
How can I listen for the creation of any new public channel on a chat service? I have seen client.channelAdded but it only works for private channels.
channelAdded
Fired when a Channel becomes visible to the Client. Fired for created
and not joined private channels and for all type of channels Client
has joined or invited to.
My use case is an internal support application where every first-time incoming SMS message from a customer user results in a new chat service channel for that particular customer user being created, and a chat message being added to the channel representing the SMS. The new channel is created via Twilio REST API.
I want to be able to have every agent user made away that there is a newly created channel (i.e. and open ticket), and then be able to join it if they want (thus making the channel public).
I supposed I could create all private channels and just invite all the agent users to the channel, but seems slightly hacky. Feels like there should be a cleaner way to do this.
Twilio developer evangelist here.
Thanks for the extra information you provided about your use case.
To start with, the channelAdded event will only fire under the circumstances that you described and not for every new public channel. Danila suggested using the webhook to trigger an event, but as you say you are already creating the channel yourself, so no need for a webhook.
Perhaps you could use a channel as a notification for your agents. Create a special channel that all logged in agents join. Then, when you create a new channel for a new open ticket, also send a message to the "open tickets" channel. You could use this channel to then simply notify your agents there is a new request, or you could fire off a function to get the latest channels so it is loaded and ready for your agent to join.
If you wanted something a little more lightweight than a chat channel for this, you could consider using a Twilio Sync list for the currently open tickets that you can then sync with your agents.
Let me know if that helps at all.
One of the possibilities to achieve desired is to add a webhook for the channel creation.
It may add member (customer support person) using REST API to the channel or will send a message to them using REST API.
I have two iOS apps, lets call it Agent app and Customer App.
I have a chat feature between these two apps, but the chats need to be recorded on the server.
I have created two Pusher Apps, one for each of the iOS apps. They both subscribe to their respective private-{id}-channel.
Now every time a message is generated from say Agent app (via HTTP request to server), I want server to create a pusher event with Agent's message on Customer's private channel.
Is it possible to achieve the above using Pusher Private channels?
One way you could achieve this is by having both users join the same channel.
Let's say you have two users: user-a and user-b. Both users subscribe to a common private channel private-chat-user-a-user-b.
let myChannel = pusher.subscribe("private-chat-user-a-user-b")
Then triggering client events on the channel
myChannel.trigger(eventName: "client-my-event", data: ["your": "data"])
Client events are a way of sending messages just between clients, without a server relaying them.
Disclosure: I work at pusher.
I wanted to record the chat on server, therefore, instead of making Customer App directly sending message on Agent App channel, I made the Customer App call my server API, which records the message and relies it on channel that Agent App is listening to.
It's not immediately clear from their site, but can one build a one to many streaming app like Ustream using TokBox web/iOS APIs? Is it limited to just chat.
I'd want to make something that captures video from the desktop or ios device and makes that video accessible at some public URL.
Yes that is capable. OpenTok works with Publishers and Subscribers. A single Publisher can publish to a session then many users can subscribe to the publishers stream using a public access token.
Check out the API it shows what you can do with it, how it does it and even shows some good demos. There are many examples of how they have used it for online chat shows and other similar one-to-many applications.
They've also very recently released their WebRTC version which makes it definitely worth a look!
I'm learning pubnub and I read their documentation but I just can't find how to manage a multi room chat box.
By default, a channel can be listened by anyone.
Subscribing to it and publishing on it is easy.
What I want is to have a main public room (so far so good) but anyone should also be able to talk privately to anyone else without the risk of being read by other users.
These dynamic rooms would be tabbed and the user should be able to go from one to another.
Another requirement would be that talking privately to someone doesn't kick you out of the other rooms you subscribed to (you can still be notified that a new message has been posted on another room while chatting)
What would be the best practice to achieve this?
Would I use different channels (created dynamically)?
Would I use one channel and filter the messages according to their status, pseudo-room id or protagonists?
Would I use multiplexing (one socket only)?
I need to know the best way to achieve this as the documentation only describes basic scenarios with a single room and there's nothing about this on the internet.
Thank you.
PS: I know PubNub doesn't recommend more than 2 channels at a time (even though I have a hard time finding the explanation of this).
PPS: I'm using punbub with socket.io
Socket.IO and PubNub Managing Private Rooms for Chat Services
You are asking for a way to create a Multiroom Chat Service, likely similar to IRC clients, where you are able to join and sit in on multiple chat rooms (on freenode.net for example). This is possible and will take some special tasks to get it right on your part.
You will start by opening Two Channels, one for the main chat room and one for your Private "ME" side chats. With this side Private "ME" channel, you will need to create a long and unpredictable session-id style channel name which typically looks like this:
YTQyOGFiNWEtNTZmZC00OGVhLTgxZjktMWE3ZmMyMzc3MTRhCg==
This is like a reference ID for the user. This ID can be used for Private 1-on-1 chats and the other room can be used for Group Chat. You will secure this Group chat using Access Control Management that we call PubNub Access Manager (PAM).
For additional Security Practices, you will need to review our security recommendations guides available here on PubNub Support for Security on our Help Desk and Knowledge Base.
Now that we have the private channels established, secure communication will be possible by sending and receiving chats via your private server (one that can provide authority) to allow messages to be relayed on a per user basis. You can learn how to do this by reading this section of the Sending Events from a Server to a Socket IO Client Documentation on PubNub.
The second channel will be for public chat for all rooms. For the Multi-tab support you will simply use the channel multiplexing feature of Socket IO on PubNub by adding new rooms via io.connect() method. Every time you open a new tab, you will open a new namespace via io.connect() of which you can have unlimited. Note however that you only should connect to no more than 2 PubNub channels at once (which you already noted in your question).
Here is the PubNub Socket IO method to subscribing to multiple feeds and categories:
Socket.IO Documentation
https://github.com/pubnub/pubnub-api/tree/493d7fc97fb683379fc78be3ca7ad9bc97eb4200/socket.io#restricting-yourself-to-a-namespace
Socket.IO Video on Vimeo
http://vimeo.com/34496366
Example Socket.IO Multiplexing Code
https://github.com/pubnub/pubnub-api/tree/493d7fc97fb683379fc78be3ca7ad9bc97eb4200/socket.io/multiplexing
As a quick conclusion, you will use secure methods to establish a private "ME" channel to send/receive messages on a per-users basis. And a public "Chat" channel that pushes all the public chat room data. Multiplexing will be important for the public chat.
The answers above were correct in 2012, but a lot has changed since then. Private chat rooms can be enabled with PubNub Access Manager, which explicitly grants Publish/Subscribe access on specific channels.
The way this works is through access tokens (aka an "Auth Key"). The developer (you) creates an Auth Key (basically any string of characters) and passes it to PubNub Access Manager. You then set the rules for this Auth Key (i.e. which channels the Auth Key can publish and/or subscribe to).
This Auth Key is provided to any device that needs access to the channel, and used when the device subscribes or publishes to the channel.
Basic docs are available here: http://www.pubnub.com/docs/javascript/tutorial/access-manager.html
Grant 60 minute read/write privilege to channel "privateChat" to an auth_key:
pubnub.grant({
channel : 'privateChat',
auth_key : 'abxyz12-auth-key-987tuv',
read : true,
write : true,
ttl : 60
});
To add to the previous answer, I'm not sure if this is just me hacking things but in order to make multi channel connections with the current socket-io library, you need to set io.connected = false; before passing in another channel config object.
For example:
var pubnub_setup = {
channel : 'public_channel',
publish_key : 'demo',
subscribe_key : 'demo'
};
var private_setup = {
channel : 'private_channel',
publish_key : 'demo',
subscribe_key : 'demo'
};
// Make your public socket connections
var publicSocket = io.connect( 'http://pubsub.pubnub.com/pub_socket', pubnub_setup );
var anotherPublicSocket = io.connect( 'http://pubsub.pubnub.com/another_pub_socket', pubnub_setup);
// Set false otherwise you keep getting back the previous created socket which is
// bound to the original channel 'public_channel'
io.connected = false;
var secretSocket = io.connect( 'http://pubsub.pubnub.com/secret_mulitplex_socket_namespace', private_setup );
Now you can keep creating new secret sockets on the private channel.