Soul Machines Web Development Kit

This section provides detailed information about the Soul Machines Web Development Kit which enables you to further enhance your Digital Person solution.

Overview

Soul Machines provides an officially supported and versioned JavaScript Web Development Kit for the purposes of implementing an interactive Digital Person within a desktop or mobile web front-end interface. At the moment, the Soul Machines Web Development Kit adheres to the ​Web Components Standard so as to provide strong encapsulation and re-usability, thus making the provided Components complimentary to React, Angular, Vue.js, and other Web Components compatible JavaScript front end frameworks.

Source

The Soul Machines Web Development Kit is provided as a minified JavaScript file (​smwebsdk.min.js​), and unminified in the ​lib​ directory of the module folder. The Web Development Kit is available via NPM. Refer to the ​NPM Module Directory Structure​ page to see a sample directory.

In addition to the NPM module, Soul Machines hosts a static minified copy of the current version of the Web Development Kit on a CDN at https://static.soulmachines.com/smwebsdk.js​.

Include Soul Machines Web SDK

When instantiated, ​smwebsdk.js​ assigns an instance to the ​window​ ​global namespace variable as ​window.smwebsdk​.

Once instantiated, there are variables, enumerations, instance functions, and Classes with Constructors available.

To include the CDN hosted Soul Machines Web SDK, include the following script tag above the HTML body:

<script src="​https://static.soulmachines.com/smwebsdk-8.min.js​"></script>

Tip: ​Use the command npm view @soulmachines/smwebsdk versions to view available smwebsdk versions on NPM. You need to run this from the directory where your NPM token file is saved, e.g. npmrc file.

Variables, Constants and Enumerations

The instance of ​window.smwebsdk​ a set of utility functions, and one enumeration definition for defining the user consented browser capabilities for the camera and microphone input.

Browser Capability Enumeration

Enum for defining User Browser Capabilities for Microphone and Camera inputs.

@readonly

@enum {string}

Index

Key

Value

1

none

SessionUserMedia.None

2

microphone

SessionUserMedia.Microphone

3

microphoneAndCamera

SessionUserMedia.MicrophoneAndCamera

Instance Functions

DetectCapabilities(): Promise<Features>

DetectCapabilities()​ ​is a convenience function that creates an instance of the Features​ Class,​  defined below. An instance of the ​Features​ class is a ​Promise that resolves with an object of values providing the capabilities the end user has opted-into, and a Boolean indicating if the Browser is supported by the Soul Machines Web SDK.

In addition to resolving with a Key-Value object of enabled Browser features, this Promise also invokes another method called​ ​detectWebRTCFeatures()​. ​Under-the-hood, this method queries the browser for the type of WebRTC it implements, and assigns​ ​isBrowserSupported​ to ​true​ if the RTC implementation is one of the following supported:

  1. RTCIceGatherer

  2. mozRTCPeerConnection

  3. webkitRTCPeerConnection

  4. RTCPeerConnection

Properties Available in Object:

Key

Value

isBrowserSupported

{boolean} - Indicates if the browser is officially supported by smwebsdk

hasMicrophone

{boolean} - Indicates if the user has provided access to microphone input

hasCamera

{boolean} - Indicates if the user has provided access to camera input

isAndroid

{boolean} - Indicates if the current device is an Android

isIos

{boolean} - Indicates if the current device is an iPhone / iPad

isEdge

{boolean} - Indicates if the current browser is MS Edge

Example Resolve Value:

{     isBrowserSupported: true, hasMicrophone: true,     hasCamera: false }

 setLogging(value: boolean): Promise<void>

This instance method enables and disables the console logging output of the SDK. In Development mode, log output is very useful and prints all WebSocket events. Once an application is moved to Production, it is best to disable this feature to minimize browser overhead and because the log output is unnecessary. One scenario where logging may be useful in a Production environment is where the end users are testing a production prototype, and sending log text files to a product team for debugging purposes.

The method has no return value, and is invoked with a single argument: a boolean value. ​true enables the logging, and​ ​false​ ​disables the logging.

Example usage to Disable ​Logging:

window.smwebsdk.setLogging(false);

Classes

Scene

Creating an instance of the Scene class connects to a Soul Machines Digital Person defined with a URI that is provided by your Customer Success team, and connects via RTC for bi-directional Audio and Video communication. The Scene Class page provides all of the necessary information to implement a Digital Person view in a Front-End User Interface.

Features

Features class, see Variables, Constants and Enumerations > Instance Functions section above.

Persona

Persona class is used to control a scene persona.

SmEvent

The Soul Machines Web SDK does not currently support SmEvent because it breaks the internal private event listener.