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
actionConfig at connectconst 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',
},
});2. Receive actionResponse
actionResponse3. Parameterized actions
Key points
4. Update attention at runtime
5. Update descriptive scene context
6. Trigger actions programmatically
Full example
API reference
actionConfig (connect option)
actionConfig (connect option)Field
Type
Description
actionResponse event
actionResponse eventType
Field
Description
updateContext (attention)
updateContext (attention)Field
Type
Description
updateSceneMetadata(items)
updateSceneMetadata(items)Field
Type
Description
sendTriggerMessage(triggerName?, triggerMessage?)
sendTriggerMessage(triggerName?, triggerMessage?)Last updated
Was this helpful?