Script tool

A script AI tool provides for an AI the capability to execute a custom back-end script. This is the most flexible AI tool that you can use with an agent. Inside the script, you can code any arbitrary capability that you want to provide to your agent.

Set up and configure the script tool

  1. Go to AI Tool and create a tool. Set the type of the tool as Script and select the script that you want the AI to be able to run.

  2. Provide a description of the tool which details what the script does.

    It is important to provide a good description, as this will determine whether the AI is aware of the capability and invokes it as required.
  3. In the Parameters tab, configure the input parameters to the script. These are filled by AI and provided to the script in the payload.

Structure of the script artifact

In the script itself, you can access the parameters as properties of variable payload. Assuming, you have created a script tool with the following parameters, for example:

  • name, type: string, description: the name of the person

  • age, type: number, description: the age of the person

Then, you can do the following in your script:

// payload is of type { name: string, age: number }
// do whatever you want with the payload
const newAge = payload.age + 10;
// provide your result to the agent in the `result` variable;
result = `The adapted age of ${name} is ${newAge}`