0

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.

rkp333
  • 341
  • 3
  • 11

2 Answers2

1

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.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thanks for the Twilio sync suggestion. This might be a good solution, esp the message stream. Bc of how I want out client UX to work, the core challenge is I need every client to see every event on the service (esp messageAdded for channels they aren't members of). The UX will allow any user to flip over to any other user's open tickets, move in and out of channels on the fly, and will need to update things like unread message counts across all tickets/channels/agents. Something that does not align well with a 'Slack' style messaging app. More like Slack with a twist. But very helpful! – rkp333 Nov 03 '17 at 22:38
  • Glad this helps! That definitely does sound like Sync should help when trying to do those extra features outside of regular chat. Let me know if there's anything else I can help with. – philnash Nov 05 '17 at 07:21
0

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 am creating the channel on the back end (Django) so I can just do any post creation task right there. However, I would like to just invite an agent user, instead of actually making them a member, which it seems would allow them to listen to that channel and receive events on the client side. – rkp333 Nov 02 '17 at 21:24
  • The main reason for trying to avoid actually adding all agents to the new channel is to avoid running into the 1000 limit on joined channels per users. If I add all agents to all "open ticket" channels, we may run into this limit in certain cases. But I will have them join all "open ticket" channels that have been "assigned" to them (manual process), this will always be a sub-100 number. – rkp333 Nov 02 '17 at 21:31