Search...
getChannel( )
Gets a chatbox channel.
Description
The getChannel()
function returns a Promise that resolves to the requested channel.
You can get a channel by specifying one of the following:
Channel ID: Gets the channel with the specified ID.
type
is ignored.Type: Gets the channel of the specified type:
- "Focused": Gets the currently focused channel.
- "Business": Gets the business channel.
Syntax
function getChannel(channelInfo: ChannelInfo): Promise<Channel>
getChannel Parameters
NAME
TYPE
DESCRIPTION
channelInfo
ChannelInfo
Channel information specifying which channel to get.
Returns
Fulfilled - When the information associated with the specific channel has been retrieved.
Return Type:
Promise<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 information about the channel associated with the specified channel ID
Copy Code
1let channelInfo = {2 "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k"3}45$w("#myChatbox").getChannel(channelInfo)6 .then((channel) => {7 const channelImage = channel.displayData.image;8 const lastMessageText = channel.messages[0].payload.text;9 })10 .catch((err) => {11 console.log(err);12 });1314/* Example channel object:15 *16 * {17 * "id": "23b345b6-c78d-9012-e3f4-567g89h0i01k",18 * "displayData": {19 * "image": "https://static.wixstatic.com/media/f43338_0f431863800d41f78e515a190c0f9dd7~mv2.png",20 * "name": "Our Chat Group"21 * },22 * "messages":[23 * {24 * "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k",25 * "type": "TEXT",26 * "summary": "Hey, how's it going?",27 * "participantId":"12a345b6-e78f-8011-f3f5-567g89h0i12j",28 * "createdAt": "2019-10-27T06:02:12.008Z",29 * "payload": {30 * "text": "Hey, how's it going?"31 * }32 * }33 * ]34 * }35 */
Get information about the currently focused chat channel
Copy Code
1let channelInfo = {2 "type": "Focused"3}45$w("#myChatbox").getChannel(channelInfo)6 .then((channel) => {7 const channelImage = channel.displayData.image;8 const lastMessageText = channel.messages[0].payload.text;9 })10 .catch((err) => {11 console.log(err);12 });1314/* Example channel object:15 *16 * {17 * "id": "23b345b6-c78d-9012-e3f4-567g89h0i01k",18 * "displayData": {19 * "image": "https://static.wixstatic.com/media/f43338_0f431863800d41f78e515a190c0f9dd7~mv2.png",20 * "name": "Our Chat Group"21 * },22 * "messages":[23 * {24 * "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k",25 * "type": "TEXT",26 * "summary": "Hey, how's it going?",27 * "participantId":"12a345b6-e78f-8011-f3f5-567g89h0i12j",28 * "createdAt": "2019-10-27T06:02:12.008Z",29 * "payload": {30 * "text": "Hey, how's it going?"31 * }32 * }33 * ]34 * }35 */