Versions Compared

Key

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

While most of the widget functionality works out of the box, sometimes you may want access to the properties and instances that the widget uses.

Accessing the Scene and Persona instance

If you run into a limitation with the widget, you may want to implement a certain feature yourself. We expose the scene and persona instance as a property on the web componentOur widget is designed to be extensible, allowing you to incorporate your own functionality on top of the features provided out-of-the-box. To enable this extensibility we have exposed our scene and persona class instances as properties of the widget. This allows you to call any of the properties or methods you see in the websdk docs.

These two properties become available after the component has successfully rendered , which can be identified on a webpage, this is signified by the new 'ready' event on the widget.

Can be used like this:

Code Block
let widget = document.getElementsByTagName('sm-widget')[0];

widget.addEventListener('ready', () => {
  // Log the objects to the console
  console.log(widget.scene);
  console.log(widget.persona);
  
  // Example of how to call methods on instances
  widget.scene.connectionState.onConnectionStateUpdated.addListener((connectionState) => {});
  widget.persona.onSpeechMarkerEvent.addListener((marker) => {});
  
});

Sending a message to the Digital Person

The A Digital Person inside the widget only responds to verbal commands. If you’d like to To send text to a Digital Person rather than speaking it, you can use the sendTextMessage method. To do implement this you can scenario select the widget element and call the function. In this example The example below shows how to send the text 'hello' is what will be sent to the a Digital Person. document.querySelector('sm-widget').sendTextMessage('hello') . A requirement of using this method is that you are connected to a session

An active connection to a Digital Person session is required to use this method. If you call it before you have connected to the method before establishing a Digital Person then it connection our SDK will throw an error.

Debugging

Currently By default the widget show warn will display warning and error logs. If you’d like prefer verbose logs, you can enable the widget to show all logs . To do thisby following these steps:

  • Open the browser console on the webpage where the widget is rendered

  • Paste in document.querySelector('sm-widget').enableDebugLogging(true) and push enter. This will enabled enable the debug logging.

  • Click the connect button. You should see a lot more logs being logged to the console.

When you want to disable the logs, repeat the same steps as above but set the debug logging to false document.querySelector('sm-widget').enableDebugLogging(false)

Content

Table of Contents