Watching a Channel

Last Edit: Feb 02 2020

Once you watch a channel, you will start receiving events for that channel. More info on that here.

To start watching a channel:


const state = await conversation.watch();
                    

final state = await channel.watch();
                    
When you watch a channel the API will ensure that the channel exists and create one if necessary and if the user is allowed to create such channel.

Response Schema

Name

Type

Description

config

object

The configuration for the channel type.

channel

object

The Channel object.

online

integer

Number of online members.

watchers

object

Users that are watching this channel. Represented as a mapping from the user id to the user object.

members

object

Channel members. Represented as a mapping from the user id to the user object.

read

object

Read messages grouped by user id. Represented as a mapping from the user id to the message object.

Watching a channel only works if you have a user set. Make sure to set a user before watching.

Unwatching

To stop watching a channel:


await state.stopWatching();
                    

await channel.stopWatching();