🖥️
carter-js v1
  • carter-js
  • 💬Conversation
    • Say
    • Interactions
    • Downvoting
    • Audio Links
    • History
  • 🎱Skills
    • Basics
  • Other Features
    • Response Times
  • More
    • Changelog
Powered by GitBook
On this page
  1. Conversation

Say

Easily speak to your carter agent

Previouscarter-jsNextInteractions

Last updated 2 years ago

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", options)
if (interaction.data) {
  const replyMessage = interaction.data.output.text
  const replyVoice = interaction.data.output.voice
}

say() takes in your message and an options object. The options object can contain a:

  • uuid: a unique user user ID. Carter supports unique users and is capable of learning and recognising individual users. If you do not provide a uuid, carter-js will create one for you using the v1 method from the package. This is returned in the response object for you to take note of if needed.

  • scene: Carter can use scenes to dictate certain elements of it's functions - namely setting conditions on triggers. If you do not pass a scene then it will be undefined as this is not a required paramater for the CarterAPI endpoint.

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.

💬
uuid