You can integrate Sendbird Calls to Sendbird Chat to provide users with a seamless experience in using Calls and Chat services by allowing them to make a call within a chat channel.
With the implementation of Calls integration to Chat, the call screen will appear when the call starts and when the call ends users will return to the chat view.
Note: To turn on Calls integration to Chat on the Sendbird Dashboard, go to Settings > Chat > Messages.
Since Calls integration to Chat is a way to add call capabilities to Sendbird Chat, it requires an app that uses Chat. If you already have one, you are ready to move to the next step. If you don’t have an app, learn how to set up Sendbird Chat from our Send first message page.
The minimum requirements for Calls integration to Chat are:
Node
npm or yarn
WebRTC API supported browsers
Sendbird Chat sample
Sendbird Chat SDK
Sendbird Calls SDK
Note: See here to find out if your browser supports WebRTC API. However, the Calls SDK doesn't support legacy WebRTC libraries in some versions of web browsers.
Sendbird Chat SDK and Sendbird Calls SDK both use singleton interfaces. Since these two SDKs work independently, create appropriate functions that can handle them together.
As written above, the Chat SDK is authenticated by using the SendbirdChat.connect() method and the Calls SDK is authenticated by using the SendBirdCall.authenticate() method.
Step 4: Log out from the Calls SDK and the Chat SDK
For integration between the Calls and Chat services, the Calls SDK provides a specific option when dialing. You can provide the group channel URL to a DialParams object of Sendbird Calls as shown below:
When a group channel URL is provided to DialParams as shown above, messages containing call information such as calling statuses and duration will be automatically sent to the channel when the call starts and ends.
The messages will contain call information in the plugins field of the BaseMessage instance which can be used to properly show information about the calls.
The sample app for Calls integration to Chat is built based on Sendbird Chat. In the chat sample app, every chat message gets rendered by a corresponding method in the Message class.
Different types of messages such as user message, file message, and admin message are shown with a corresponding HTMLElement, which is returned by the Message._createElement() method, offering a more intuitive user experience.
For UI components for Calls integration to Chat, add _createCallElement() method to the Message class with a stylesheet. If the _createCallElement() method is called, the returned HTMLElement will show the following when users make or receive a call.
An example of UI components you can create is demonstrated in the following files in the sample app:
the _createCallElement() method of the Message.js file and the .call-message class of the message.scss file.
To show the registered UI components, refer to the steps below to identify which messages are associated with the Calls SDK.
The BaseMessage class from Sendbird Chat SDK has a field called plugins where you can store additional information to default values. The key-value plugins are delivered as [string: any] dictionary.
When a call is made from the Calls SDK, the plugin field of a message associated with the call will contain the following information: vendor: sendbird, type : call.
Then, for the messages that have these fields, show the UI component created.
In the _createElement() method of the Message.js file from the chat sample, add the following:
The call view provides events for users such as ending a call, muting or unmuting the microphone, or offers local and remote video views on a user’s screen.
Calls integration to Chat can provide a seamless user experience by allowing users to initiate a new call directly from a channel by tapping the messages that contain call information.
When you create an element for a message bubble, add an onclick event handler to the element which would call the dial() method and allow users to make a call by tapping the bubble.