Avatar Activation with WebSDK
This documentation page will guide you through the process of activating and managing avatars using the Avaturn WebSDK. You'll learn how to initialize the SDK, connect to sessions, and interact with a
1. WebSDK initalization
Load the WebSDK
Begin by loading the WebSDK into your project. You can include it directly in your HTML or import it as a module in your JavaScript.
OR
Initialize the SDK with a Session Token
After loading the SDK, initialize it using the session token obtained from your backend. This token is crucial for establishing a connection with the avatar session.
2. Connecting to a Session
Connect to the Avatar Session
Use the WebSDK to connect to the active session. This connection allows the frontend to interact with the avatar, enabling real-time communication and control.
3. Avatar Interaction
Send Commands to the Avatar
Once connected, you can send commands to the avatar, such as making it speak or perform certain actions. These interactions are handled in real-time through the WebSDK.
Handle Avatar Events
Subscribe to avatar events to respond to specific actions, like when the avatar starts or stops speaking. This allows you to create a more interactive and dynamic user experience.
4. Disconnecting and Cleanup
Disconnect from the Session
When the session is no longer needed, disconnect from it to free up resources. This is especially important in applications where multiple sessions or avatars might be used.
Cleanup
Ensure that you clean up any resources associated with the SDK, especially if you’re navigating away from the page or terminating the session.
Important Considerations
Session Token: Always ensure that the session token is valid and securely passed to the frontend to avoid unauthorized access.
Event Handling: Utilize event listeners to create a responsive and interactive environment, providing users with real-time feedback based on the avatar’s actions.
Resource Management: Properly disconnect and clean up sessions to optimize performance and resource usage.
Last updated