Skip to main content

InworldClient

Module: Inworld.AI. Namespace: Inworld.

This is the base class for sending and receiving data from the server.

Inspector Variables

VariableDescription
Server ConfigThe current server to which this client is connected.
Scene Full NameThe full name of the current scene.
API KeyThe API key used to load scenes. Note that if InworldGameData in InworldController has a value, this API Key setting is invalid.
API SecretThe API Secret used to load scenes. Note that if InworldGameData in InworldController has a value, this API Secret setting is invalid.
Custom TokenThe JSON token string used to load scenes. You can obtain the token from the Inworld Web SDK.
Public WorkspaceThe string of the public workspace, used for workspace sharing.
Auto SceneIf checked, we'll automatically find the first scene containing the characters.
ContinuationFor the new Session Continuation state to load.
Max Waiting List SizeSets the max size of the cached outgoing packets.
100 by default.

Events

EventDescription
OnStatusChangedTriggered when the status of this component changes.
OnErrorReceivedTriggered when any error received.
OnPacketSentTriggered when any InworldPackets are sent.
OnGlobalPacketReceivedTriggered when the InworldPackets are received with a source of WORLD.
OnPacketReceivedTriggered when any InworldPackets from the server are received.

Properties

PropertyDescription
ServerGets or sets the current InworldServerConfig to which this client is connected.
LiveSessionDataGets the live session data.
Key by character's Character ID (aka brainName) value by its agent ID.
SessionHistoryGet/Set the session history.
AutoSceneSearchGet/Set if the client will automatically search for a scene for the selected characters.
ServerGets/Sets the current Inworld server this client is connecting.
TokenGets or sets the token used to log in to the Runtime server of Inworld.
CurrentSceneGets/Sets the current full name of the Inworld scene.
IsTokenValidGets if the current token is valid.
StatusGets or sets the current status of the Inworld client.
If set, it will invoke the OnStatusChanged events.
ErrorMessageGets or sets the error message.
ErrorGets/Sets the InworldError.
If the error is no retry, it'll also set the status of this client to be error.

API

FunctionDescriptionParameters
GetCharacterDataByFullNameGet the InworldCharacterData by characters' full name."characterFullNames": the request characters' Brain ID.
GetCharacterDataByIDGets the InworldCharacterData corresponding to the given agentID.agentID: target ID to search.
GetSceneNameByCharacterGets the scene name by the given target characters.
PrepareSessionPrepare the session. If the session is freshly established. Please call this.
SendFeedbackAsyncSend Feedback data to server.interactionID: The feedback bubble's interactionID
correlationID:The feedback bubble's correlationID
feedback: The actual feedback content.
GetHistoryAsyncGet the session history data. Stored at property SessionHistory.
By default, it'll be stored in the memory only, Please store it to your local storage for future use.
sceneFullName: the full name of the target scene.
SendPacketsA generalized function to send packets.
Will automatically be called in outgoing queue.

Can be called directly by API.
GetAccessTokenRetrieves the access token. This function should be implemented by the child class.
ReconnectReconnects the session or starts a new session if the current session is invalid.
GetLiveSessionInfoRetrieves the live session information once the scene is loaded.
The returned LoadSceneResponse contains the session ID and all the live session IDs for each InworldCharacter in this InworldScene.
InitWithCustomTokenUses the input JSON string of a token instead of API key/secret to load the scene.
This token can be obtained from other applications, such as the InworldWebSDK.
token: the custom token to initialize.
StartSessionStarts the session using the session ID.
DisconnectDisconnects from the Inworld Server.
UnloadSceneUnload curren scene. Make sure to be called before loading another scene.
LoadSceneSends a LoadScene request to the Inworld Server.sceneFullName: the full string of the scene to load.
SendCapabilitiesSend Capabilities to Inworld Server.
It should be sent immediately after session started to enable all the conversations.
SendSessionConfigSend Session Config to Inworld Server.
It should be sent right after sending Capabilities.
SendClientConfigSend Client Config to Inworld Server.
It should be sent right after sending Session Config.
SendUserConfigSend User Config to Inworld Server.
It should be sent right after sending Client Config.
SendHistorySend the previous dialog (New version) to specific scene.
Can be supported by either previous state (base64) or previous dialog (actor: text)
SendTextToNew Send messages to an InworldCharacter in this current scene.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID.
2. New method support broadcasting to multiple characters.
textToSend:the message to send.
characters:the list of the characters full name.
SendTextSends messages to an InworldCharacter in the current scene.characterID: the live session ID of the character to send.
textToSend: the message to send.
SendCancelEventToNew Send the CancelResponse Event to InworldServer to interrupt the character's speaking.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID
2. New method support broadcasting to multiple characters.
interactionID: the handle of the dialog context that needs to be cancelled.
utteranceID:the current utterance ID that needs to be cancelled.
characters: the full name of the characters in the scene.
SendCancelEventSends the CancelResponse Event to the Inworld Server to interrupt the character's speaking.characterID: the live session ID of the character to send.
utteranceID:the current utterance ID that needs to be cancelled.
interactionID: the handle of the dialog context that needs to be cancelled.
SendTriggerToNew Send the trigger to an InworldCharacter in the current scene.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID.
2. New method support broadcasting to multiple characters.
triggerName: the name of the trigger to send.
parameters: the parameters and their values for the triggers.
charactersthe full name of the characters in the scene.
SendTriggerSends a trigger to an InworldCharacter in the current scene.charID: the live session ID of the character to send.
triggerName: the name of the trigger to send.
parameters: the parameters and their values for the triggers.
StartAudioToNew Send AUDIO_SESSION_START control events to server.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID
2. New method support broadcasting to multiple characters.
"characters: the full name of the characters to send.
StartAudioSends AUDIO_SESSION_START control events to the server.
Without sending this message, all the audio data will be discarded by the server.
However, if you send this event twice in a row without sending StopAudio(), the Inworld server will also throw exceptions and terminate the session.
charID: the live session ID of the character to send.
StopAudioToNew Send AUDIO_SESSION_END control events to server to.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID.
2. New method support broadcasting to multiple characters.
characters: the full name of the character to send.
StopAudioSends AUDIO_SESSION_END control events to the server.charID: the live session ID of the character to send.
SendAudioToNew Send the wav data to server to a specific character.
Need to make sure that AUDIO_SESSION_START control event has been sent to server.
NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID.
2. New method support broadcasting to multiple characters.
Only the base64 string of the wave data is supported by Inworld server.
Additionally, the sample rate of the wave data has to be 16000, mono channel.
base64:the base64 string of the wave data to send.
characters: the full name of the character to send.
SendAudioSends the WAV data to the server. Ensure that the AUDIO_SESSION_START control event has been sent to the server.
Only the base64 string of the wave data is supported by the Inworld server.
Additionally, the sample rate of the wave data must be 16000, mono channel.
charID: the live session ID of the character to send.
base64: the base64 string of the wave data to send.

InworldWebSocketClient

Module: Inworld.AI. Namespace: Inworld. Inherits from InworldClient

From the version 3.3 and later, as the NDK client is deprecated, all the logic of the InworldWebSocketClient has been merged to InworldClient.