Open a chat

Open chat with StreamId

The openStream function exposed by the SDK allows you to open a conversation or switch to a different conversation, specified by its streamId.

In Focus mode, if a selector is provided, the SDK will either create a new iFrame and add the chat in it, or, if the container already included a chat, it will update the chat.

If the second parameter is not provided, or if in Collaboration mode, the chat will be opened in the main iFrame (the one that was created with the render function).

Parameters

ParameterTypeDescription

streamId

string

Stream ID of the chat conversation

containerSelector

string | undefined

Selector of the container to add the new Embedded Mode iFrame into (Focus mode only)

Returns

A Promise that resolves when the chat is ready. See the promise definition below.

Example

Open a different chat in the main iFrame:

window.symphony.openStream('sdaP4miqUAe8OyLsJRmb/H///n+esBXidA==')

Open a chat in a specific container:

<div id="ecp-chat"></div>
// You can also refer to a div by ID, with #
window.symphony.openStream('sdaP4miqUAe8OyLsJRmb/H///n+esBXidA==', '#ecp-chat');

Open chat with users

The startRoom function will let you start a direct message or group chat with specific users.

Similarly to the openStream function, while in Focus mode, you can pass a containerSelector parameter to open the chat in a specific container.

If a direct message or group chat with the user(s) already exists, it will open it. If it does not exist, it will create and open one.

Parameters

ParameterTypeDescription

Users

Array<string>

Array of users. Users can be represented by their user ID or email address.

containerSelector

string | undefined

Selector of the container in which to add the new Embedded Mode iFrame (Focus mode only)

Returns

A Promise that resolves when the chat is ready. See the promise definition here.

Example

Open a direct message in the main iFrame with a user identified by their user ID:

window.symphony.startRoom(['71811853191063'])

Open a group chat in a specific container with two users (one identified by their user ID, and one identified by their email address):

<div id="ecp-chat"></div>
window.symphony.startRoom(['71811853191063', 'john.doe@symphony.com'], '#ecp-chat');

Returned promise

The functions openStream and startRoom return a JavaScript Promise that will resolve once the chat is displayed. The promise has the following interface:

Success

ParameterTypeDescription

streamId

string | undefined

Stream ID of the chat displayed.

userIds

string[] | undefined

List of user IDs

Last updated