{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":22646,"path":"intelligent-experiences/add-script-new.md","title":"Add a script tool to an AI agent","bundle":null,"doc_type":null,"release":"australia","body":"\n# Add a script tool to an AI agent\n\nAdd a script tool to an AI agent to enable it to execute custom scripts to perform specialized tasks.\n\n## Before you begin\n\nRole required: sn\\_aia.admin\n\n## About this task\n\nA script tool allows AI agents to execute custom scripts to perform specialized tasks. When adding a script tool, you can configure its script inputs, execution mode, output display, and processing messages. You can reference the scripts that come with AI agents associated with AI applications as examples to help you write custom scripts.\n\n## Procedure\n\n1.  In the Tools section, select **Add tools**, then **Create new tool**, then select **Script**.\n\n2.  Choose whether to create a new script or use an existing one.\n\n    Select **A new script** to create a new script, or select **An existing one** to use a previously created script.\n\n3.  If you want to use an existing script, select the name of the script from the **Select a script** dropdown.\n\n    The script's inputs and script content are populated automatically.\n\n4.  Add script inputs under **Script inputs**.\n\n    Select **Add an input** to add each required input. For each input, enter the input name, description, and mark whether it is mandatory.\n\n5.  Write or edit the script in the **Script** field.\n\n    Only string inputs are allowed. The script should return outputs as an object where the keys are understandable by the language model.\n\n    Field names must match exactly. A typo in a variable or column name produces a run-time error that reads as a tool failure.\n\n    **Note:** For improved security, use GlideRecordSecure instead of GlideRecord and addUserEncodedQuery\\(\\) instead of addEncodedQuery\\(\\).\n\n6.  Enter a name for the tool in the **Name** field.\n\n7.  Enter a detailed description of the tool in the **Description for this AI agent** field.\n\n    A thorough description helps the AI agent understand what the tool does and when to use it.\n\n8.  Select an execution mode under **Execution mode**.\n\n    Choose **Supervised** to require human oversight when the tool executes, or **Autonomous** to allow the tool to run without human intervention.\n\n9.  Toggle **Display output to users** to control whether the tool's output is shown to users.\n\n10. If display output is enabled, select an output widget from the **Widget** dropdown.\n\n    Widgets can only be used by assistants built in Premium Chat experiences. Select the widget type that best formats the tool's output for users.\n\n11. Choose whether to display a refined widget message under **Display refined widget message**.\n\n12. Expand the **Advanced settings** section to configure output transformation and processing messages.\n\n    1.  Select an output transformation format from the **Output transformation format** dropdown.\n\n        Raw output data usually needs to be transformed into a format that is user-friendly and readable. You can also transform data into smaller formats to reduce the amount of data the AI agent needs to analyze. Transforming data involves tradeoffs between data completeness and latency.\n\n        The available output transformation formats are:\n\n        -   **None**: Output data isn't changed into a different format and users will see raw data.\n        -   **Concise**: Output data is changed into the most minimal format for users, with less data for the AI agent to analyze.\n        -   **Verbose**: Output data is changed into a summary-like format for users, with slightly less data for the AI agent to analyze.\n        -   **Paraphrase**: Output data is changed into a format featuring direct statements for users, with no reduction in data.\n        -   **Custom**: Output data is changed into a format you specify \\(consider data loss and performance issues\\).\n    2.  Write processing messages for users under **Write processing messages for users**.\n\n        Describe the action that happens while the tool is running in the **In-progress message** field and the final action when the tool completes in the **Completion message** field. For example, users can see \"Executing script\" when the tool is in progress and \"Script execution complete\" when the tool is done.\n\n\n## Result\n\nYou have added a script tool to your AI agent with the appropriate script inputs, execution mode, output settings, and processing messages configured.\n\n"}}