Last Edit: Feb 02 2020

Inviting Users

Stream Chat provides the ability to invite users to a channel via the channel method with the invites array. Upon invitation, the end-user will receive a notification that they were invited to the specified channel.

See the following for an example on how to invite a user by adding an invites array containing the user ID:

const invite ='messaging', 'awesome-chat', {
    name: 'Founder Chat',
    members: ['thierry', 'tommaso', 'nick'],
    invites: ['nick'],

await invite.create();

$channel = $client->Channel('messaging', 'team-chat-2', 
			'members'=>['thierry', 'jenny', 'elon'],
$state   = $channel->create('thierry');

Accepting an Invite

In order to accept an invite, you must use call the acceptInvite method. The acceptInvite method accepts and object with an optional message property. Please see below for an example of how to call acceptInvite:

The message can be used for system messages for display within the channel (e.g. "Nick joined this channel!").

// initialize the channel
const channel ='messaging', 'awesome-chat');

// accept the invite
await channel.acceptInvite({
    message: { text: 'Nick joined this channel!' },

// initialize the channel
$channel = $client->Channel('messaging', 'team-chat-5');

// accept the invite
$accept = $channel->acceptInvite(['user_id'=>'elon']);

Rejecting an Invite

To reject an invite, call the rejectInvite method. This method does not require a user ID as it pulls the user ID from the current session in store from the setUser call.

await channel.rejectInvite();

$reject = $channel->rejectInvite(['user_id'=>'elon']);

Query for Accepted Invites

Querying for accepted invites is done via the queryChannels method. This allows you to return a list of accepted invites with a single call. See below for an example:

const invites = client.queryChannels({
    invite: 'accepted',

$invites = $client->queryChannels(['invite' => 'accepted'],[], ['user_id' => 'jenny']);

Query for Rejected Invites

Similar to querying for accepted invites, you can query for rejected invites with queryChannels. See below for an example:

const rejected = client.queryChannels({
    invite: 'rejected',

$invites = $client->queryChannels(['invite' => 'rejected'],[], ['user_id' => 'jenny']);