Play options

By default, Alan AI can respond or execute a command specified in the play() function only when the Agentic Interface button in the client app is activated. To change this behavior, pass the opts() parameter to the play() function. This parameter allows you to specify one or more play settings that determine how the Agentic Interface must behave when the play() function is executed.

You can define the following options:

Option

Action type

Agent type

Description

force:true

command

AI Chat, voice agent

Execute a command even if the Agentic Interface button is not activated in the client app

activate:true

command

AI Chat, voice agent

Activate the Agentic Interface button in the client app before a command is executed

deactivate:true

response, command

AI Chat, voice agent

Deactivate the Agentic Interface button in the client app after a response is given or command is executed

markdown:true

response

AI Chat

Allow displaying markdown-formatted text in responses

audio:false

response

AI Chat

Disable voice output for responses

Assume you want to allow users to set a timer using Alan AI Agentic Interface on a web page. The Agentic Interface should behave in the following way:

  1. When the timer is set, the Agentic Interface sends a confirmation message.

  2. When the timer expires, an alert is displayed and the Agentic Interface sends a message: Time is up.

Dialog script
intent('Set a 1-minute timer', p => {
    p.play('Sure, 1 minute, starting now');
    setTimeout(() => {
        p.play({command: 'stopTimer'}, opts({force:true}));
        p.play('Time is up');
    }, 60000)
})
Client app
<script>
  var alanBtnInstance = alanBtn({
    key: "YOUR-ALAN-AI-KEY",
    onCommand: function (commandData) {
      if (commandData.command === "stopTimer") {
        alert('Timer is up')
      }
    },
    rootEl: document.getElementById("alan-btn"),
  });
</script>