rkp333
rkp333

Reputation: 381

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.

Upvotes: 0

Views: 503

Answers (2)

philnash
philnash

Reputation: 73029

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.

Upvotes: 1

Danila Sukharev
Danila Sukharev

Reputation: 86

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.

Upvotes: 0

Related Questions