Script Layers & Execution Order
SILVIA’s internal compiler pulls together all of the scripts in a Brain File from a series of Script Fields. The Headers and Global script layers are universal to the Brain File. Each Behavior, and each individual Exuder, has its own Validation, Pre-Exuder, and Post-Exuder Script Fields. They execute in the following order:
Input 1. Behavior Validation 2. Exuder Validation 3. Behavior Pre-Exuder 4. Exuder Pre-Exuder 5. Behavior Post-Exuder 6. Exuder Post-Exuder End.
Each script layer has its own purpose:
- Headers: Headers of a C# script. This is usually where you put the “using” directives, i.e., “using System;”, “using CognitiveCode.Silvia.Api;”, etc.
- Global: Script that is true globally throughout the application.
- Validation: Script that determines if the Behavior will be considered for interaction in deeper levels in language searches. If the Behavior returns a false value, it will not be considered.
- Pre-Exuder: Script that does something prior to the output generation. If the Behavior is selected to be invoked, the pre-Exuder script is executed before output of any associated Exuder.
- Post-Exuder: Script that does something post output generation. After the output is sent back to the application, additional actions can be performed, for instance talking to a database, moving to another Behavior, or setting some post output conditions.
It is worth noting that any time there are multiple layers of scripts on a single Behavior, checking to be sure all Variables referenced are being set or tested for at the right times will save debugging time. Pay attention to your Debug Console and look for SILVIA throwing any “Exception In Script” errors, many of which are non-critical but can easily stop your Brain File from functioning the way it was planned – generally SILVIA will name the Behavior and the Script Stage that couldn’t execute. See the App Flow Viewer to get a more visual map of where and when Variables are used by Behaviors.