Alterdesk Chat Embed API

Chat Embed is an easy way to include the full chat functionality. This includes functionalities like uploading and downloading attachments.

Using the Chat Embed

Calling the chat endpoint on GroupChat and Aux GroupChat resources will output a URL that can be used in an IFrame.

<iframe src="[chat-embed-url]" id="chat-iframe" referrerpolicy="strict-origin-when-cross-origin"></iframe>

Host Validation

The generated URL from the endpoint has extra host domain validation and a separate Application Client ID with domain whitelist is required for this to work. Please contact Support for more information.

Deeper integration

It is possible to more deeply integrate the chat embed with the host page by including the following script: https://api.alterdesk.com/public/js/chat-embed-helper.min.js

This script contains the ChatEmbed Helper Class which can be used as follows:

<script src="https://api.alterdesk.com/public/js/chat-embed-helper.min.js"></script>
<script type="text/javascript">
  var iframe = document.getElementById('chat-iframe');
  var chatEmbed = new ChatEmbed(iframe);

  chatEmbed.on('video-call-join', function() {
    // Retrieve videoEmbed URL from backend and open in another iframe
  });
</script>

ChatEmbed Helper Functions

new ChatEmbed(iframe)

Create a new instance of the ChatEmbed Helper class.

Parameters:
Name Type Description
iframe Inline Frame Handle to the Chat Embed iframe.

EventEmitter

The ChatEmbed Helper is an EventEmitter where you can subscribe on the events defined below.

on(eventName, function)

Add a listener for the specified event.

Parameters:
Name Type Description
eventName String Event from the table below.
function Function Callback to trigger when the event is emitted.

Events

Event Argument Description
started The chat has setup and is now available.
video-call-join The user has clicked on button to join video call.

changeStatus(status)

Change the status of the user.

Parameters:
Name Type Description
status String New status of the user. Available options: online, dnd, away, offline