Say

Easily speak to your carter character

You can speak to your carter agent using Carter.say(). Carter.say() returns a CarterInteraction.

// Assuming you have already created a Carter object called carter

const options = {
  uuid: "A UNIQUE USER ID" // Optional
  scene: "level-1" // Optional
}

// Send a message to your Carter agent
const interaction = await carter.say("Hello", 'your-player-id', speak=True) // Only the message is mandatory
if (interaction.data) {
  const replyMessage = interaction.response_text
}

say() takes in your message and an optional playerId. carter-js will generate an id for you if you do not provide one. This will be different each time but can be extracted from the interaction object.

Speak

Carter's audio URL can cause some latency, and can therefore be toggled at a Class and Function level. Passing the speak Boolean to any function call will allow you to override the default behaviour.

Interactions

Carter interactions are discussed more in the next section, however please be aware that if Carter does not return a valid response then the data property of the interaction will be undefined, make sure to check for this either by checking the property itself or through the ok property before you try to access it.

Last updated