Channel Initialization

Last Edit: Mar 03 2020

Here’s how you can initialize a single channel for later use. Please note that this will only create a channel object without making any API call. Once the channel is initialized you can use one of these methods: query, watch, create.


const conversation = client.channel('messaging', 'channel-name', {
    name: 'Founder Chat',
    image: 'http://bit.ly/2O35mws',
    members: ['thierry', 'tommaso'],
});

await conversation.create();
                    

conversation = client.channel(
    'messaging', 'thierry-tommaso-1', 
    data: {
      'name'   => 'Founder Chat',
      'image'  => 'http://bit.ly/2O35mws',
      'members => ['thierry', 'tommaso'],
    }
)
                    

final channel = client.channel(
  "messaging",
  id: "travel",
  extraData: {
    "name": "Founder Chat",
    "image": "http://bit.ly/2O35mws",
    "members": ["thierry", "tommaso"],
  },
);
                    

$channelConf = [ 
	'name' => 'Founder Chat',
	'image' => 'http://bit.ly/2O35mws',
  'members' => ['thierry', 'tommaso']
];

$channel = $client->Channel("messaging", "thierry-tommaso-1", $channelConf);
                    

val channelController = client.channel(channelType, channelId)
                    

Channel Initialization Parameters

Name Type Description Default Optional
type string The channel type. Default types are livestream, messaging, team, gaming and commerce. You can also create your own types. -
id string The channel id (optional). If you don't specify an ID the ID will be generated based on the list of members. (max length 64 characters) -
channel data string Extra data for the channel. Must not exceed 5KB in size. default
The channel data can contain any number of custom fields. However, there are a few reserved fields that Stream uses:

Reserved Fields for Custom Channel Data

Name

Type

Description

name

string

The channel name. No special meaning, but by default the UI component will try to render this if the property is present.

image

string

The Channel mage. Again there is no special meaning but by default, the UI component will try to render this is the property is present.

members

array

The members participating in this Channel. Note that you don't need to specify members for a live stream or other public chat. You only need to specify the members if you want to limit access of this chat to these members and subscribe them to future updates