Skip to main content

🤖 AI tools

Tags: JavaScript, React, Vue, Angular, Website, Web App

What are AI tools?​

AI tools allow you to create deep integrations between your app / website and Kai (our AI bot). A few use-cases might include:

  • A banking app allowing to initiate transactions
  • Performing a password reset directly in the messenger
  • Canceling orders
  • ...

The possibilities are almost endless. The following example shows how to add a new AI tool allowing users to initiate bank transactions directly inside Kai.

Ticket custom data

Specify AI tools​

const transactionTool = {
// Name the tool. Only lowecase letters and - as well as _ are allowed.
name: 'send-money',
// Describe the tool. This can also contain further instructions for the LLM.
description: 'Send money to a given contact.',
// Let the LLM know what the tool is doing. This will allow Kai to update the customer accordingly.
response: 'The transfer got initiated but not completed yet. The user must confirm the transfer in the banking app.',
// Set the execution type to auto or button.
executionType: 'auto',
// Specify the parameters (it's also possible to pass an empty array)
parameters: [{
name: 'amount',
description: 'The amount of money to send. Must be positive and provided by the user.',
type: 'number',
required: true
}, {
name: 'contact',
description: 'The contact to send money to.',
type: 'string',
enum: ["Alice", "Bob"], // Optional
required: true
}]
};

// Add all available tools to the array.
const tools = [transactionTool, ...];

// Set the AI tools.
Gleap.setAiTools(tools);

Execution type​

auto: The tool will be executed automatically.

button: Kai adds a button to it's reply, that allows the user to execute the tool. The tool will not be executed automatically

Ticket custom data

Perform actions​

Gleap.on("tool-execution", (tool) => {
if (tool.name === "send-money") {
const amount = tool.params.amount;
const contact = tool.params.contact;

// Initiate the transfer here.
// tool.params contains all parameters that were specified in the AI tool above.
}
});