`channelAdded` event from `twilio-chat` - twilio

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.

Related

Adding participants to existing calls in Signal iOS

I have created an iOS app using signal private messenger (Signal Messenger). The application supports one to one calls using WebRTC.
Now I have a requirement of adding participants to existing calls.
Is this possible using the existing framework? Or do I have to implement additional code on server/client to support it?
You can find https://github.com/googlecodelabs/webrtc-web/issues/72 discussion with possible way to adapt WebRTC to multiple connections, while in other issue using https://github.com/medooze/media-server is advised. Therefore WebRTC do not offers this feature easily implemented.
Signal-iOS and Signal-Android now have only feature requests for conference calls https://community.signalusers.org/t/conference-calls/870 and https://github.com/signalapp/Signal-iOS/issues/1804
So you can either wait until Signal developers would release that or contribute on the project and deliver that feature.
The concept behind adding participant in the current call is known as renegotiation.
In this peers exchange the session description packet again with each other and negotiate ice candidates.
In order to achieve this in the signal app, you first have to know the flow of single call and make custom messages to flow to renegotiate the same.

How to receive an event notification, like "channelAdded", when a new public channel is created

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.

Mobile Chat application on Google App Engine and Socket.IO

I am creating a chat application with Node.JS's Socket.IO and there is a couple things I need clarification on.
I am implementing offline messaging in my app meaning that when a user opens the app he will receive all the messages he missed when they were online.
This is my approach:
1) Client opens the app and is subscribed/joins a room
2) The client sends a message to Socket.IO
3) Socket.IO inserts the message in some kind of database/datastore
4) When client tries to retrieve the messages it is pulled from the database/datastore and saved on the users phone then it is deleted from the database.
Is this a correct approach?
I was looking at online and some people suggested using task/message queues like Google App Engines Task Queue but I am not sure how this works.
Your approach sounds OK, but I wouldn't delete messages from a DB, at least not immediately after the client receives them.
From your question it seems that you're not currently saving the messages to a database.
This approach has some drawbacks; for example, the user can't view their chat history on a device that was not connected when some of the messages were sent.
There are 2 ways I can think of to do it in a more elegant manner:
Save all messages to DB. on websocket connection and reconnections, fetch all messages newer than your latest message (This approach assumes no edit functionality in your chat, as edits will not be fetched this way). The latter can be implemented using either HTTP or WebSockets.
If you don't want to store the messages in your server, then you should implement some sort of persistent cache in the device used to send the messages. This is very similar to your original solution, except that instead of storing the messages in a database, you're storing them on the user's device. this does require some logic to detect when messages are received, and when the recipient reconnects, in order to trigger sending the missing messages.
The first approach is much better for the general use case in my opinion, but it depends on your use case.

support center app with twilio or pubnub

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?

Is there any way in slack api to add interactive buttons without a slack app

I'm new to the slack api. I was thinking about posting an interactive message to my team channel via an incoming webhook. But the docs say that for an incoming message to work, it requires an app to be created with Interactive messages enabled. Is there any workaround to make it happen without the app?
No, it is not possible, you need an app (this does not mean you'd have to make your app public, mind you)
Posting messages with buttons requires registering a Slack app.
Interactive messages cannot be posted using a custom integration.

Resources