Integrating with voice or video providers
Layer does not provide real-time voice or video capabilities. However, it is easy to integrate third-party providers into a Layer conversation. This guide describes the high-level architecture to achieving such an integration; it is not limited to or targeted at one specific voice or video call provider.
- Our goal is to provide a link or similar UI control in the conversation that, when tapped, takes the user into a voice or video call.
- Since Layer supports arbitrary message types, this can be implemented as a custom, pre-defined message type. For example, we can create a message with a single message part, whose type is
application/voip-linkand body is the link to the call.
- Your app should recognize the
application/voip-linkMIME type, and render the button or message cell you wish to show when receiving a call.
- Acquiring the link to the call depends on the API your chose provider offers. Most provider APIs follow similar patterns to integrate:
- They require an authentication token, or a key/secret pair, used to initialize their client or authenticate an API request. These typically come from the dashboard of your provider.
- They provide an SDK method or API call to “create a conference” or “create a meeting”. This usually returns a call ID.
- Some providers have a URL format that accepts a call ID and serves as a join link. For example, if your call ID was
call-123, the provider may recognized the URL
https://example.com/join/call-123. If so, you can simply send that link in the
bodyof the Layer message; the receiving client will be able to open a standard HTTPS link. Otherwise, your chosen provider will typically include a “join conference” SDK method or API endpoint. In that case, you should simply send the call ID in the body of the Layer message, and on the receiving client, call the provider’s SDK method or API endpoint when the user wishes to join the call.
- If the provider provides Webhooks or callbacks as the status of the call changes (members join or leave, call ending, etc), you may choose to update the display of the call button or message cell to reflect this status change. In such a case, you may choose to retain a reference to the view rendering the state of the call, and bind it to a data model that represents the state of the call.