Use background scripts and Generative AI Controller Generic Prompt to interact directly with the generative AI model API.
Before you begin
You must be on Vancouver patch 2 or above to script with sn_one_extend.OneExtendUtil objects.
Role required: admin
About this task
With scripting, you have greater flexibility in how you use Generative AI Controller capabilities across the platform. By accessing the capability programmatically, you can capture the LLM's response and use that to determine next actions.
For more information on tracking Generative AI Controller usage, see Monitoring Now Assist usage.
Procedure
-
Navigate to .
-
Create the text content for a Generic Prompt by creating a
request array with a singular executionRequests object.
-
Inside the
executionRequests, add the payload and capabilityID attributes.
The capabilityID is the sys_id of the capability on the OneExtend Capabilities (sys_one_extend_capability) table, such as Generic Prompt.
-
Add the required inputs as attributes in the
payload object.
| Capability |
Required attributes |
| Generic Prompt |
prompt: Prompt for the generative AI to respond to. |
| Generate Content |
topic: Subject for content generation. |
| Sentiment Analysis |
utterance: Text to analyze for user sentiment. |
| Summarize |
textToSummarize: Topic for the AI to generate a summary. |
The following is an example request array for the Generic Prompt capability.
var request = {
"executionRequests": [
{
"payload": {
"prompt": "Can you act like my business partner and give me some advice on a pitch?"
},
"capabilityId": "0c90ca79533121106b38ddeeff7b12d7"
}
]
};
-
Call the
execute method on sn_one_extend.OneExtendUtil.
- Optional:
To display the response after running the background script, print the response in readable JSON by using the following code:
gs.info(JSON.stringify(sn_one_extend.OneExtendUtil.execute(request)));