Event handling
There may be times when you want even more fine tuned control of your client application, and to synchronise your website with the state of the digital human. For this, we provide message events from the digital human application that may be consumed by your web client. To do this, you may listen to window event UneeqMessage.
The below code example demonstrates how you can listen for messages, and in this case update the class list of the body element when the session becomes live. There are many more message events you may want to listen for, these are listed in the table below.
Event Name | Description |
ReadyToStart | The application has loaded and configuration validated. The session may now be started by calling uneeqStartSession() |
SessionStateUpdate | Session state has been updated (Initial, WaitingToStart, AvatarUnavailable, MajorError, Live, Paused, Ended) |
LayoutModeUpdate | The layout mode has been updated: LayoutModeUpdate.layoutMode |
SessionId | The digital human session ID |
AvatarAvailable | At least one digital human is available to be started |
AvatarUnavailable | No digital humans are available to be started |
AvatarQuestionText | A question was asked to the Digital Human |
AvatarAnswer | Digital human has a response |
AvatarAnswerContent | Content has been provided by the NLP system to be rendered |
CustomData | JSON data that was provided by the NLP system in the 'instructions' field. This data can be used to pass custom instructions from the NLP system into your front end application. For example, you could set some customData of a product that you want to display on the website. |
StartedSpeaking | Digital human has begun speaking |
FinishedSpeaking | Digital human has finished speaking |
DeviceEnabled | Permission to use recording devices has been granted by the user. |
RecordingStarted | A voice recording has been initiated |
RecordingStopped | A voice recording has been ended |
DigitalHumanPlayedInMutedModeSuccess | Digital human audio could not be played due to browsers auto play policy. Digital human was started with audio muted. You may call uneeqUnmuteDigitalHuman() following user click/key event to unmute the digital human. |
DigitalHumanUnmuted | The digital human was unmuted, or started in unmuted mode. |
DigitalHumanVideoError | An error occurred with the digital human video. Refer to contents of message for details. |
DigitalHumanFailedToPlay | The digital human video could not be played for some reason. Most likely blocked due to the browsers auto play policy (the user has not interacted with the page before attempting to play audio). |
DigitalHumanUnmuted | The digital human was unmuted. |
ServiceUnavailable | Something went wrong, refer to contained message for details. |
SpeechTranscription | An interim or final speech transcription of the users speech was received. Speech Recognition mode only. |
CustomMetadataUpdated | Chat metadata has been updated successfully. The message will provide the newly set metadata value. |
CallToActionDismissed | The call to action box has been dismissed by the user. |
DevicePermissionAllowed | [Deprecated] |
AvatarTextInputFinished | [Deprecated] |
Instructions | [Deprecated] |