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

The most common use: telling the character who it is speaking with before any dialogue begins.

Scenario: The player creates a character and enters the world. The NPC should greet them by name and acknowledge their class.

using System.Collections;
using System.Linq;
using Convai.Scripts;
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 ConvaiRoomManager _roomManager;

    private IEnumerator Start()
    {
        while (ConvaiRoomManager.Instance == null)
            yield return null;

        _roomManager = ConvaiRoomManager.Instance;

        while (!_roomManager.IsConnectedToRoom)
            yield return null;

        // runLlm: "true" triggers an immediate character response.
        // The full audio pipeline must be ready before sending — waiting for
        // IsConnectedToRoom alone is not sufficient. The bot participant joins,
        // publishes its audio track, and the AudioStream is initialised
        // asynchronously after the room connects. Sending before all three
        // stages complete causes the TTS response to be silently dropped.
        while (_roomManager.NpcToParticipantMap == null ||
               !_roomManager.NpcToParticipantMap.Values.Any(d => d.AudioStream != null))
        {
            yield return null;
        }

        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 = _roomManager.UpdateDynamicContext(context, mode: "replace", runLlm: "true");
        if (!sent)
            Debug.LogWarning("[PlayerGreeting] UpdateDynamicContext returned false.");
    }
}

replace ensures no stale context from a previous session carries over. runLlm: "true" triggers an immediate greeting response.


Injecting the Learner Profile

At session start, push the learner's name, role, and current course. Every character in the session is immediately personalized without any dashboard reconfiguration.


Module Progression

As the trainee advances to a new module, replace the context with the module's objectives. The character immediately knows what to focus on — no reconfiguration required.


Language Tutor Proficiency Level

A language learning tutor adjusts its vocabulary, sentence complexity, and correction style based on the learner's current proficiency level. A single call at session start — or whenever the level changes.

Injecting Emotional State

Dynamic Context is not limited to facts. Plain-language instructions work equally well for shaping character tone and behavior on the fly.

Scenario: A companion NPC's mood should shift based on what is happening in the scene — calm before a battle, tense during it, relieved after.

runLlm: "false" updates the character's disposition silently — the new tone will surface naturally in the next exchange rather than triggering an unsolicited remark.


Intermediate

Reactive Game State

As the player progresses, the world changes. Dynamic Context lets those changes reach the character in real time.

Scenario: A shopkeeper NPC should always be aware of the player's current gold, recent events, and completed quests.

Passive state (gold, world news) uses runLlm: "false" — it colors future replies without prompting unsolicited comments. Quest completions use runLlm: "true" because a reaction is expected.


Silent Event Accumulation

In high-frequency event scenarios — rapid loot drops, kill streaks, bonus triggers — reacting to every event creates noise. The correct pattern is to accumulate silently and respond only when something meaningful happens, or when the user initiates conversation.

Scenario: A combat commentator tracks kill events throughout a fight. The character stays quiet during the action but has full awareness of everything that happened when the player finally speaks.

This keeps the character's intervention meaningful. It has full awareness of the event stream but speaks at deliberate moments rather than reacting to every trigger.


Performance-Driven Coaching Difficulty

A sales training simulator tracks the trainee's real-time performance score. When the score shifts enough to cross a difficulty tier, the character's coaching strategy updates mid-session — no restart needed.


Branching Compliance Scenario State

A compliance training simulation where each trainee decision advances a scenario branch. The AI colleague NPC always has full awareness of what decisions were made, their consequences, and the accumulated compliance score.


Medical Simulation Patient Vitals Monitor

A clinical training simulation where a patient NPC's vitals change in real time. The character absorbs routine fluctuations silently but escalates when values cross clinically significant thresholds — without spoiling the diagnosis for the trainee.


Advanced

Cross-Scenario Competency Gap Tracker

A multi-scenario training platform tracks which competencies the learner has demonstrated or missed across all scenarios in a session. Each new scenario is informed by the accumulated competency profile so the AI can naturally probe weak areas without the learner being aware of it.

Usage across scenarios:


Real-Time Procedural Assessment

A high-fidelity procedural trainer (flight simulator, surgical trainer, industrial safety) monitors every action against a defined checklist. Actions accumulate silently. When the same step fails repeatedly, the AI instructor intervenes with a Socratic question — never giving the answer, but guiding the trainee's thinking.

What this pattern enforces:

  • The instructor has full awareness of every action without constantly interrupting — the character is always listening

  • The Socratic threshold prevents the instructor from becoming a hint machine — it speaks only when a genuine learning barrier is detected

  • The cooldown prevents rapid-fire interventions that would undermine independent thinking

  • The final debrief draws on the accumulated event log for a substantive, evidence-based assessment rather than a generic summary


Reactive Character with Autonomous Response Thresholds

The most sophisticated pattern: the character monitors a continuous stream of game state updates and decides autonomously when to speak — without waiting for the user to initiate. This is a reactive architecture. The character is always listening, but only surfaces when something crosses a meaningful threshold.

Scenario: A companion NPC tracks the player's health passively throughout the session, warns at a moderate drop, and urgently intervenes at a critical level — all without any input from the player.

Silent updates via runLlm: "false" keep the character's knowledge current at all times. runLlm: "true" is reserved exclusively for moments that genuinely warrant a proactive response. The threshold logic ensures the character intervenes once — not repeatedly — until the situation resolves.

Last updated

Was this helpful?