Send text messages to the AI agent programmatically
sendText
method.
sendText
method that handles both events for you:
sendText
will generate a response only if the model is currently not generating anything.sendText
method accepts an optional second parameter with these options:
Option | Type | Default | Description |
---|---|---|---|
cancelOngoing | boolean | false | Cancel any ongoing response generation before sending the new text |
sendText
will generate a response only if the model is currently not generating anything.
If you call sendText
while the AI is responding, you have two options:
Option 1: Handle the error (default behavior)
cancelOngoing: true
, simultaneous calls will fail with this error: