Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

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 component. 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 by the new 'ready' event on the widget.

Can be used like this:

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 widget only responds to verbal commands. If you’d like to send text to a Digital Person rather than speaking it, you can use the sendTextMessage method. To do this you can select the widget element and call the function. In this example the text 'hello' is what will be sent to the Digital Person document.querySelector('sm-widget').sendTextMessage('hello') . A requirement of using this method is that you are connected to a session. If you call it before you have connected to a Digital Person then it will throw an error.

Debugging

Currently the widget show warn and error logs. If you’d like verbose logs, you can enable the widget to show all logs. To do this:

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

  • Paste in document.querySelector('sm-widget').enableDebugLogging(true) and push enter. This will enabled 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

  • No labels