Skip to content

JavaScript API

Procedures

You can create procedures in our dashboard, these actions can do a range of tasks, including but not limited to:

  • showing a followup question
  • Execute custom javascript
  • Call an API endpoint
  • Start a live chat

By default, these procedures show as buttons in our AI component for the end-user to use. There is also an option to immediately execute an action by skipping the human in the loop. In that case, the action won’t be shown to the user first but will immediately execute.

Procedures can require variables to execute. The variable you set on a procedure will show in a form to the end-user. The user has to fill out the form with the required field before the action can be executed. These can be any questions like requesting a name, email, selecting a category, etc.

Variables can also be dependent on each other. This means that the value of the first variable will determine if a second variable will be shown or skipped. This way you can create a tree-like structure in the form questions the user will have to fill in.

Procedure data will be stored in the conversation and shown in the conversation details in the Unless dashboard. If a variable is already set, the AI won’t ask for it again in the form. So if the email is already known, the form will not prompt the user to fill in their email. If you want the user to fill in the variable even if it is already known, then you can use the “Re-ask every time” switch on the variable details to turn that on.

Finally, you can use a variable in the procedure by using our placeholder syntax: {{variable_name}}. For example, if you have a custom-javascript action you can create something like this:

// if statement depending on the variable value
if ('{{type_select}}' === 'opening_times') {
// send a prompt to the AI.
Txt.sendMessage('What are the opening times')
} else {
// just showing here you can insert the variable anywhere.
window.location.href = 'https://google.com?q={{type_select}}'
}

To show a procedure to the user, you need to set guidance conditions. You can do this in the guidance tab. Procedures can be shown when:

  • Agentic
  • When a specific document is used to answer a question
  • On negative feedback (thumbs down)
  • After an unanswered question
  • After every single response
  • After the user is detected inactive

There is also a special condition called “Display only if rule matches”. Here you can add your own custom javascript that will determine if the action will be shown to the end-user.