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.

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.

To generate a new token you can use the new API getToken available in CTLive SDKCTLive 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
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) {
    console.log("[VIDYO] Token", data.token);// the Agent 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 + "]" );

  contact.responseVideoUpgrade(Boolean <true/false>, String <divID>);

// CreateExample: aAgent Videoaccept Connectorthe media escalation
  VCcontact.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 () {
              console.log("[VIDYO] CONNECTED");
              vidyoConnector.RegisterParticipantEventListener(
                {
                  onJoined: VIDYO_onJoined,
                  onLeft: VIDYO_onLeft,
                  onDynamicChanged: VIDYO_onDynamicChanged,
                  onLoudestChanged: VIDYO_onLoudestChanged
                }
              );
            },
            onFailure: function (reason) {
              console.log("[VIDYO] CONNECT ERROR [" + reason + "]");
            },
            onDisconnected: function (reason) {
              console.log("[VIDYO] DISCONNECTED [" + 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

Use the RegisterParticipantEventListener API to get notified about participant events.

...

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

...

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 [responseVideoUpgrade] event", event.response);
   // no action is required by the integration.
   // the audio / video connection will be automatically engaged 
   // upon receipt of the positive 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("[CTLIVE AGENT SDK] PARTICIPANT Event [" + eventName + "]");
  }
);

Name

Type

Description

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.

onLoudestChanged

function

Callback that is triggered when
  • The “participant” parameter will contains an ordered array of participants according to rank.

  • onLoudestChanged: a new participant becomes the loudest, based on active speech detection.

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.