Search.../

getChannelList( )

Gets a list of available chat channels for a site visitor.

Description

The getChannelList() function returns a Promise that resolves to a list of available channels for the site visitor.

Syntax

function getChannelList(): Promise<Array<Channel>>

getChannelList Parameters

This function does not take any parameters.

Returns

Fulfilled - When the list of channels has been retrieved.

Return Type:

Promise<Array<Channel>>
NAME
TYPE
DESCRIPTION
id
string

ID of the channel.

displayData
DisplayData

Display information associated with the channel.

messages
Array<Message>

An array of messages sent over the channel. Currently only the last message is included.

Was this helpful?

Get a list of available chat channels

Copy Code
1$w("#myChatbox").getChannelList()
2 .then((channels) => {
3 // Get channel image of first channel in list
4 const firstChannelImage = channels[0].displayData.image;
5 // Get most recent message text of first channel in list
6 const firstChannelText = channels[0].messages[0].payload.text;
7 })
8 .catch((err) => {
9 console.log(err);
10 });
11
12/* Example channel list:
13 *
14 * [
15 * {
16 * "id": "23b345b6-c78d-9012-e3f4-567g89h0i01k",
17 * "displayData": {
18 * "image": "https://static.wixstatic.com/media/f43338_0f431863800d41f78e515a190c0f9dd7~mv2.png",
19 * "name": "Our Chat Group"
20 * },
21 * "messages":[
22 * {
23 * "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k",
24 * "type": "TEXT",
25 * "summary": "Hey, how's it going?",
26 * "participantId": "12a345b6-e78f-8011-f3f5-567g89h0i12j",
27 * "createdAt": "2019-10-27T06:02:12.008Z",
28 * "payload": {
29 * "text": "Hey, how's it going?"
30 * }
31 * }
32 * ]
33 * },
34 * {...} // Next channel
35 * ]
36 */