Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Vidyo.io is a platform as a service (PaaS) that enables developers to provide high-quality, real-time video communication capabilities. The service includes the VidyoClient SDK, which provides the APIs for integrating such communication capabilities into a variety of applications and workflows.

To start using Vidyo.io services load the Javascript Vidyo Library into your web application as shown below.

Static or Dynamic loading require a global callback function. When the library loads the callback will be invoked.

Static loading

Code Block
languagejs
<script src="https://static.vidyo.io/latest/javascript/VidyoClient/VidyoClient.js?onload=onVidyoClientLoaded"></script>

Dynamic loading via jQuery

The loadVidyo function returns a promise that notifies the correct loading of the library.CTLive offers a built-in Vidyo integration by extending the contact chat object adding methods and properties to control the media audio/video escalation.

Media escalation feature

CTLive offers a basic media escalation feature. A customer with an ongoing chat can request an engagement of the audio/video channel by creating a video conference. The CTLive SDK library offers a notification and response API allowing you to perform a request-response-engagement flow on the video channel.

Request API (on customer side)

Code Block
languagejs
function loadVidyo() {
  console.log("[CTLIVE WIDGET] Start Video Escalation...");
  return new Promise( 
    function(resolve, reject) {
      if (typeof window.VC === "undefined") {

        // Vidyo Global Callback
        window.onVidyoClientLoaded = function (status) {
          console.log("[VIDYO] SDK EVENT");
          if (typeof status !== "undefined") {
            switch (status.state) {
              case "READY":
                console.log("[VIDYO] READY");
                // The library is operating normally
                // After the VidyoClient/VidyoConnector is successfully initialized,
                // A global VC object will become available.
                resolve();
                break;
              case "RETRYING":
                console.log("[VIDYO] RETRYING");
                break;
              case "FAILED":
                console.log("[VIDYO] FAILED");
                break;
              case "FAILEDVERSION":
                console.log("[VIDYO] FAILEDVERSION");
                break;
              case "NOTAVAILABLE":
                console.log("[VIDYO] NOTAVAILABLE");  
                break;
            }
          }
        };
        $.getScript("https://static.vidyo.io/latest/javascript/VidyoClient/VidyoClient.js?onload=CTLIVE_VIDYO_LOADED&webrtc=true&plugin=false", 
          function () {
            console.log("[VIDYO] SDK Library loaded");
          }
        );
      } else {
        // Library already loaded
        resolve();
      }
    }
  );
};

After the VidyoClient/VidyoConnector is successfully initialized, global VC object will become available.

Connect to a Video Room or create a new one

In order to join a video room each participant must provide a new token. Tokens are used to authenticate each endpoint (mobile, web, or native desktop app) to the vidyo.io service and enable video chat sessions.

A token is generated by combining a user name, the application ID and an expiration time, then signing these with the developer key. The resulting string is the token.

Application ID, expiration time and developer key are stored in CTLive MongoDB configuration.

...

contact.requestVideoUpgrade(String <divID>, Boolean <useAudio>, Boolean <useVideo>)
// Example:
contact.requestVideoUpgrade("videoPanel", true, true);
  • divID: Element div/panel ID where the composited video will be rendered

  • useAudio: flag that indicates whether to perform a media escalation on the current chat using the audio channel

  • useVideo: flag that indicates whether to perform a media escalation on the current chat using the video channel

Request Event notification (available on both agent/customer engagement)

Register a callback on contact object for the “requestVideoUpgrade” event.

Code Block
languagejs
LIVECHATSDKcontact.LIVECHAT.getVideoToken(<chat_id>, <nickname>).then(on("requestVideoUpgrade", 
  function (dataevent) {
    // the Agent  console.log("[VIDYO] Token", data.token);can accept/refuse the video media escalation
  }
);

Start a Video Session

Once the token is generated you have to create a new Vidyo Connector Object and use the Connect method to join an existing video room or create a new one.

A DOM element ID must be reserved as display area where the video streaming will be render.

Each Video room is identified by using the CTLive Chat ID.

Response API (available on both agent/customer engagement)

Code Block
languagejs
// Generate new Token
LIVECHATSDK.LIVECHAT.getVideoToken(AD_VIDEO_Obj.chat_id, "AGENT").then(
  function (data) {
    var TokenID = data.token;
    console.log("[VIDYO] Token [" + TokenID + "]" );

    // Create a Video Connector
    VC.CreateVidyoConnector(
      {
        viewId: "divPanelVideo", // DOM element reserved to video render
        viewStyle: "VIDYO_CONNECTORVIEWSTYLE_Default",
        remoteParticipants: 2, // Max number of participants
        logFileFilter: "info", // Log levels
        logFileName: "",
        userData: ""
      }
    ).then(
      function(vidyoConnector) {
        // Connect to Video Room
        vidyoConnector.Connect(
          {
            host: "prod.vidyo.io",
            token: TokenID, //Generated Token
            displayName: "CUSTOMER",
            resourceId: "CHAT_DEFAULT_e9f75bfb-b8cc-4141-8c74-646d45636a14", // Video Conference Name, use the CTLive CHAT ID
            onSuccess: function () {
          contact.responseVideoUpgrade(Boolean <true/false>, String <divID>);

// Example: Agent accept the media escalation
contact.responseVideoUpgrade(true, "videoPanel");
// Example: agent rejected the media escalation
contact.responseVideoUpgrade(false, "videoPanel");

Response Event notification (available on both agent/customer engagement)

Code Block
languagejs
contact.on("responseVideoUpgrade",
  function (event) {
   console.log("On [VIDYOresponseVideoUpgrade] CONNECTEDevent", event.response);
   // no action is required by the     vidyoConnector.RegisterParticipantEventListener(integration.
   // the audio / video connection will be automatically engaged 
  { // upon receipt of the              onJoined: VIDYO_onJoined,
                  onLeft: VIDYO_onLeft,
                  onDynamicChanged: VIDYO_onDynamicChanged,
                  onLoudestChanged: VIDYO_onLoudestChanged
                }
              );
            },
            onFailure: function (reasonpositive response.
  }
)

Participants Events Callback

A custom integration can bind a callback to receive notification about the participants members of the video engagement session.

Code Block
languagejs
contact.bindVideoParticipantEvent(
  function(event, eventName, participant) {
              console.log("[VIDYO]CTLIVE CONNECT ERROR [" + reason + "]");
            },
            onDisconnected: function (reason) {
              console.log("[VIDYO] DISCONNECTED [AGENT SDK] PARTICIPANT Event [" + reason + "]");
              console.log("[VIDYO] Call Disconnect() API on Video Connector");
              vidyoConnector.Disconnect().then(
                function (result) {
                  console.log("[VIDYO] Call Disable() API on Video Connector");
                  vidyoConnector.Disable();
                }
              );
            }
          }
          ).catch( function (err) {console.err(err); }
        );
      }
    );
  }
).catch( function(err) { console.err(err); } );

Participants events

...

eventName + "]");
  }
);
Callback that is triggered when

Name

Type

Description

onJoined

function

Callback that is triggered when another participant joins a conference.

onLeft

function

Callback that is triggered when an existing participant leaves a conference.

onDynamicChanged

function

event

object

jQuery standard event notification object

eventName

String

Participant event name. It can be one of the following values:

  • onJoined: a new participant joined the video room.

  • onLeft: a participant left the video room.

  • onDynamicChanged: the order of participants has changed, based on their importance according to active speech detection. The “participant” parameter will contains an ordered array of participants according to rank.

  • onLoudestChanged

function

Callback that is triggered when
  • : a new participant becomes the loudest, based on active speech detection.

Detect a Media escalation

CTLive offers a basic media escalation feature. A customer with an ongoing chat can request an engagement of the video channel by creating a video conference. The CTLive SDK library offers a notification and response API allowing you to perform a request-response-engagement flow on the video channel.

Request API (on customer side)

Code Block
LIVECHAT.requestVideoUpgrade(<chat_id>);

Request Event notification (on agent side)

Register a callback on contact object for the “requestVideoUpgrade” event.

Code Block
languagejs
contact.on("requestVideoUpgrade", 
  function (event) {
    // the Agent can accept/refuse the video media escalation
  }
);

Response API (on agent side)

Code Block
languagejs
LIVECHATSDK.LIVECHAT.responseVideoUpgrade(<chat_id>, <boolean>);
// if true the Agent integration generate a new token
// and create a new Video Connector Object as shown in the previous section

Response Event notification (on customer side)

Code Block
contact.on("responseVideoUpgrade",
  function (event) {
   console.log("On [responseVideoUpgrade] event", event.response);
   // The CTLive Widget generate a new Token and create a new Video Connector Object
  }
)

Documentation

Vidyo Developer Center: https://developer.vidyo.io/#/documentation

...

participant

Object

The object contains the participant information.

Disconnecting Video session

Use the contact.videoDisconnecAndDestruct method to disconnect the participant from the video room.

To engage a new video session, a new media escalation must be requested.