Use Cases
Explore practical use cases for Dynamic Context and learn how it improves character responsiveness, relevance, and contextual awareness in conversations.
Beginner
Personalizing the Conversation
using System.Collections;
using Convai.Runtime.Components;
using Convai.Runtime.Room;
using UnityEngine;
/// <summary>
/// Injects player identity into the active Convai session at session start.
/// The character receives this context before the first exchange and can
/// greet the player by name and class without any dashboard reconfiguration.
/// </summary>
public class PlayerGreeting : MonoBehaviour
{
[SerializeField] private string _playerName = "Aria";
[SerializeField] private string _playerClass = "Ranger";
private IConvaiRoomConnectionService _connectionService;
private IEnumerator Start()
{
while (true)
{
ConvaiManager manager = ConvaiManager.ActiveManager;
if (manager != null && manager.TryGetRoomConnectionService(out _connectionService))
break;
yield return null;
}
if (_connectionService.IsConnected)
SendGreeting();
else
_connectionService.Connected += OnConnected;
}
private void OnConnected()
{
_connectionService.Connected -= OnConnected;
SendGreeting();
}
private void SendGreeting()
{
string context =
$"You are speaking with {_playerName}, a level 1 {_playerClass}. " +
"Greet them warmly and welcome them to the world.";
// replace — ensures no stale context from a previous session carries over.
// runLlm: true — triggers an immediate greeting response.
bool sent = _connectionService.UpdateDynamicContext(context, mode: "replace", runLlm: "true");
if (!sent)
Debug.LogWarning("[PlayerGreeting] UpdateDynamicContext returned false.");
}
private void OnDestroy()
{
if (_connectionService != null)
_connectionService.Connected -= OnConnected;
}
}Injecting the Learner Profile
Module Progression
Language Tutor Proficiency Level
Injecting Emotional State
Intermediate
Reactive Game State
Silent Event Accumulation
Performance-Driven Coaching Difficulty
Branching Compliance Scenario State
Medical Simulation Patient Vitals Monitor
Advanced
Cross-Scenario Competency Gap Tracker
Real-Time Procedural Assessment
Reactive Character with Autonomous Response Thresholds
Last updated
Was this helpful?