From RunID to AI Analysis: ASK_AI in Automic Automation
Now that we’ve covered the configuration and the AI job, I’d like to introduce another way to execute AI prompts. This is an “old” familiar feature that was introduced back in version 24.4: ASK_AI. ASK_AI is not a job type, but rather an Automic script function. It is characterized by its close integration with the Automic runtime environment. To obtain an analysis of an Automic job execution, you only need to specify its RunID and the report type.
:SET &ANSWER# = ASK_AI("Analysiere den bereitgestellten Report auf Deutsch. Prüfe,ob er Fehlermeldungen enthält, und nenne die jeweilige Textstelle. Kontext: {data} Zusatzanweisung: {query}", "JOB T.JS.UNIX.ERROR with RunID 1242003, analyze report type REP", "Falls der Report eine Fehlermeldung enthält, beschreibe eine mögliche Lösung.")As you can see from the example, the ASK_AI syntax is not complicated. The function has four parameters, but only the first one is required.
The first parameter defines the AI prompt, which—as I mentioned in my first article—is crucial for the final result. It’s a good idea to use an AI to create and refine a prompt.
Especially in business process automation, where traceable and consistent results are crucial, absolutely everything must be specified in detail in the prompt. You must define which sources should be used and, more importantly, which ones should not. ASK_AI differs from an AI-JOB in how it specifies data sources. The second parameter in ASK_AI is used to specify data sources. This can also be an Automic RunID, allowing for the analysis of that job execution. The third parameter should be used to specify how the result will be processed further.
The second parameter provides additional context or data. The third parameter contains a supplementary question or instruction. Both values can be incorporated into the prompt using the placeholders {data} and {query}.
It has also proven useful to have another AI review the initial versions of a prompt specifically for boundary conditions. In this case, the AI serves as a sparring partner.
ASK_AI also offers the ability to create AI queries that build on one another. The BEGIN_AI_CHAT function is available for this purpose, which generates a ChatID. This is then passed as the fourth parameter to the ASK_AI call. The ASK_AI help documentation is very detailed and includes many good examples.
One challenge with ASK_AI is reliably detecting faulty calls. You should check whether an error occurred during execution. This can be implemented as follows, for example:
:SET &RESULT# = ASK_AI("Tell me a joke in German.",, )
:SET &ERRNR# = SYS_LAST_ERR_NR ()
:IF &ERRNR# NE "0"
: SET &ERRINS# = SYS_LAST_ERR_INS ()
: SET &MESSAGE# = GET_MSG_TXT (&ERRNR#,&ERRINS#)
: P "ASK_AI call failed: &MESSAGE#"
: EXIT 1
:ENDIFHowever, this only detects a technical error in the query, not a factually incorrect or incomplete AI response!
This raises the question: When should I use ASK_AI, and when should I use an AI-JOB?
ASK_AI’s seamless integration into the Automic runtime environment makes it the preferred solution for analyzing Automic job runs and operational activities. An AI job is ideal when the AI task needs to be modeled as a standalone, executable Automic object with its own configuration.
UC_AI_PROMPTS STATIC-VARA from client 0
The AI features offered in AWI—“Analyze …” and the Automation Assistant—naturally also use AI prompts. These are defined in the UC_AI_PROMPTS variable in client 0 and can also be edited there. They can also serve as a good example of prompts in the Automic context.
Outlook
That wraps up my little series for now. More will surely follow in the future.