{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":22645,"path":"intelligent-experiences/add-script-ai-agent.md","title":"Add a script to an AI agent","bundle":null,"doc_type":null,"release":"australia","body":"\n# Add a script to an AI agent\n\nCreate a script to add it to an AI agent in AI Agent Studio. With scripts, you can use the scriptable APIs and back-end integration to support the AI agent.\n\n## Before you begin\n\nRole required: sn\\_aia.admin\n\n## Procedure\n\n1.  Navigate to **All** &gt; **AI Agent Studio** &gt; **Create and manage** &gt; **AI agents**.\n\n2.  Open the AI agent that you want to add a script to and navigate to the Add tools and information section.\n\n3.  In the **Add tool** drop-down list, select **Script**.\n\n4.  On the form, fill in the fields.\n\n<table id=\"table_hg4_cbv_cdc\"><thead><tr><th>\n\nFields\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nSelect a type of record operation to add\n\n</td><td>\n\nIf you select **An existing one**, you can select a record operation tool used by the current AI agent or any other AI agent. You can make changes to the settings of that tool to fit the needs of your specific AI agent.\n\n</td></tr><tr><td>\n\nName\n\n</td><td>\n\nName that you want to specify for your script.\n\n</td></tr><tr><td>\n\nDescription\n\n</td><td>\n\nDescription of the script and what it's going to do to assist your AI agent.**Note:** This description is sent to the large language model \\(LLM\\).\n\n</td></tr><tr><td>\n\nScript inputs\n\n</td><td>\n\nInput name and description to use in the script. The LLM uses the name and description to determine what value should be used at runtime. Example: Input name is **task\\_record\\_sys\\_id** and description is **sys\\_id of the Task Record, this is mandatory**.\n\n</td></tr><tr><td>\n\nScript\n\n</td><td>\n\nJavaScript code that includes an object class or a function for your script. **Note:** For improved security, use GlideRecordSecure instead of GlideRecord and addUserEncodedQuery\\(\\) instead of addEncodedQuery\\(\\).\n\n</td></tr><tr><td>\n\nExecution mode\n\n</td><td>\n\nMode of execution for your script:-   **Supervised**: Inputs from your human agent are required during the execution of this tool while the AI agent runs.\n-   **Autonomous**: Doesn't require any input from your live agent during the execution of this tool while the AI agent runs.\n\n\n</td></tr><tr><td>\n\nDisplay output\n\n</td><td>\n\nPermission to display the output of the tool execution in the ServiceNow Otto panel or in Virtual Agent:-   **Yes**\n-   **No**\nIf you want the AI agent to work in Off Glide architecture with Premium Chat experience, you must turn-on the **Display output** toggle. When the toggle is turned-on, you can add widgets that can be used in assistants built with Premium Chat experiences. The widget configuration includes:\n\n-   **Widget**: Defines the display output to render the content in a better user experience. You can select the widget from the drop-down.\n-   **Require widget transformation**: An additional LLM call is required to transform the raw tool. If you choose to skip this transformation step, the tool output will be directly mapped to the widget.\n    -   **Yes**\n    -   **No**\n-   **Display refined widget message**: Refines the widget message when configured.\n    -   **Yes**\n    -   **No**\n**Note:** The display output as a toggle is exclusively available for the Premium Chat experience when the Off Glide Conversation Server plugin \\(com.glide.cs.offglide\\) is installed. If the plugin is not installed, you will continue to access the standard display output options.\n\n</td></tr><tr><td colspan=\"2\">\n\nAdvanced settings\n\n</td></tr><tr><td>\n\nSelect an output transformation format\n\n</td><td>\n\nStyle for the LLM to present the results as it passes information between tools and to other agents. Out transformation formats:-   None\n-   Concise\n-   Paragraph\n-   Summary\n-   Custom\n\n\n</td></tr><tr><td>\n\nWrite processing messages for users\n\n</td><td>\n\nMessage to display to users during tool execution.-   In-progress message: Write an in-progress message to be displayed to end-users while the tool is running.\n-   Completion message: Write a completion message to be displayed to end-users once the tool finishes running.\n\n\n</td></tr></tbody>\n</table>5.  Select **Add**.\n\n    A script tool is added in the Scripts section on the Add tools and information page.\n\n\n"}}