For the complete documentation index, see llms.txt. This page is also available as Markdown.

Actions

Actions let the character decide what to do in your scene. You declare the available affordances at connect time; the character decides when and what to do based on the conversation.

1. Configure actionConfig at connect

const client = useConvaiClient({
  apiKey: '...',
  characterId: '...',
  actionConfig: {
    // Action names the character can emit
    actions: ['Move To', 'Pick Up', 'Drop', 'Follow', 'Wave', 'Attack'],

    // Objects in the scene the character can act on
    objects: [
      { name: 'sword',  description: 'A sharp steel sword on the ground' },
      { name: 'chest',  description: 'A wooden treasure chest in the corner' },
      { name: 'torch',  description: 'A flaming torch on the wall' },
    ],

    // Other characters the bot can reference or act on
    characters: [
      { name: 'Player', bio: 'The current user' },
      { name: 'Guard',  bio: 'A nearby guard NPC' },
    ],

    // Optional: object the character starts focused on
    current_attention_object: 'sword',
  },
});

Rules:

  • actions, objects, and characters define the only valid affordances for this session.

  • current_attention_object must match an entry in objects[].name.

  • If the set of available actions or objects changes, reconnect with an updated actionConfig.


2. Receive actionResponse

Subscribe to actionResponse to get the character's action decisions after each turn. The payload is typed — import ConvaiAction and ActionResponseEvent from the SDK.

  • Actions are ordered — execute them in sequence.

  • target is optional; some actions (e.g. "Wave") have no target.

  • An empty actions array is not an error — the character simply chose not to act.


3. Parameterized actions

An action with a target is parameterized: the character acts on a specific object or character rather than performing a bare gesture. The base action name comes from actionConfig.actions[], and the target resolves to a name from actionConfig.objects[] or actionConfig.characters[].

If the user says "pick up the sword and give it to the guard", a single turn can emit:

Key points

  • target always matches a declared name from actionConfig.objects[] or actionConfig.characters[] — the character cannot invent targets, so it is safe to use as a lookup key into your scene graph.

  • The same base action can appear both parameterized and simple depending on what the character decides ("Wave" vs "Wave" → "Player"); branch on the presence of target, not on the action name.

  • Scene metadata from updateSceneMetadata is descriptive only and never appears as a target — promote anything actable into actionConfig.objects.


4. Update attention at runtime

Tell the character which object the player is currently looking at using updateContext. The character uses this to resolve "it", "that", "here".

current_attention_object must match an entry in actionConfig.objects[].name.


5. Update descriptive scene context

Use updateSceneMetadata for environment changes the character should know about. This is descriptive only — it does not add new action targets.

If the character needs to act on something, it must be in actionConfig.objects.


6. Trigger actions programmatically

Use sendTriggerMessage to make the character speak and act without user input — for scripted events or cinematics.


Full example


API reference

actionConfig (connect option)

Field
Type
Description

actions

string[]

Action names the character can emit

objects

{ name, description }[]

Objects in the scene

characters

{ name, bio }[]

Other characters

current_attention_object

string?

Initial focus object

actionResponse event

Type
Field
Description

ActionResponseEvent

actions: ConvaiAction[]

Ordered actions for this turn; empty = no action

ConvaiAction

name: string

Base action name from actionConfig.actions[]

ConvaiAction

target?: string

Parameterized target — a name from actionConfig.objects[] / characters[]; absent for simple actions

updateContext (attention)

Field
Type
Description

text

string?

Optional context text

mode

"append" | "replace" | "reset"

How to apply text

run_llm

"true" | "false" | "auto"

Whether to trigger a response

current_attention_object

string?

New focus object, or "" to clear

updateSceneMetadata(items)

Field
Type
Description

items

{ name, description }[]

Descriptive scene elements

sendTriggerMessage(triggerName?, triggerMessage?)

Programmatically triggers a character response. Both arguments are optional.

Last updated

Was this helpful?