Scout Workflow Logic and State

Understanding workflow execution and state management

Workflows are designed to manage complex processes by chaining together a series of actions or blocks. Understanding the logical flow of workflows and how state is managed between them is crucial for effective automation and integration.

Logical Flow of Workflows

Workflows operate by executing a sequence of blocks, each performing specific tasks that contribute to the overall process. These blocks can include operations like data retrieval, network requests, transformation, and output generation. The logical flow begins with the initiation of the workflow, typically triggered by an input or event, which then progresses through each block in the specified order.

State Management

State in workflows is managed through the passing of data between blocks. Each block can produce outputs that become inputs for subsequent blocks, facilitating a dynamic flow of information. This is achieved using placeholders in the form of {{block_id.your_custom_field}} or {{block_id.output}}. For instance, in the screenshot above, {{inputs.user_message}} can be used to represent the initial input provided to the workflow, while {{collection_vp81p.output}} refers to the output generated by the collection block, identified by its ID.

To use the workflow input in the query against my collection block, I would reference it in the query field of the collection block’s configuration like so:

Then, continuing with the same example, I may pass a prompt to my LLM block that contains the output, as referenced by {{collection_vp81p.output}} in the content field, from the collection block query:

Global Variables

Scout provides several global variables that are automatically available in all workflow blocks. These variables can be used in Jinja templates to access current date and time information in various formats and time zones.

Date and Time Variables

The following global variables are available for accessing current date and time information:

  • {{__exp_global.current_date}} - Current date in format “Tuesday, March 2, 2022” (local system time)
  • {{__exp_global.current_time}} - Current time in format “10:30 AM” (local system time)
  • {{__exp_global.current_datetime}} - Current date and time in format “Tuesday, March 2, 2022 at 10:30 AM” (local system time)

Time Zone Variables

For specific time zones, the following variables are available (all in 12-hour format with AM/PM):

  • {{__exp_global.current_time_utc}} - Current UTC time in format “10:30 AM”
  • {{__exp_global.current_time_eastern}} - Current Eastern time in format “5:30 AM”
  • {{__exp_global.current_time_central}} - Current Central time in format “4:30 AM”
  • {{__exp_global.current_time_mountain}} - Current Mountain time in format “3:30 AM”
  • {{__exp_global.current_time_pacific}} - Current Pacific time in format “2:30 AM”
  • {{__exp_global.current_time_alaska}} - Current Alaska time in format “1:30 AM”
  • {{__exp_global.current_time_hawaii}} - Current Hawaii time in format “12:30 AM”

All time zone variables use human-readable 12-hour format with AM/PM and automatically handle Daylight Saving Time (DST) where applicable.

Usage Examples

You can use these global variables in any block that supports Jinja templating. For example:

  • In an LLM block prompt: “Today is {{__exp_global.current_date}}. Please provide a summary…”
  • In a text block: “Report generated on {{__exp_global.current_datetime}}
  • In an email subject: “Daily Update - {{__exp_global.current_time_pacific}}

Execution Considerations

Ensure that each block is configured to correctly process the inputs it receives and that it outputs data in a format usable by subsequent blocks. Reference blocks documentation for details on each specific block type.

In addition, consider the following:

  • Error Handling: Implement strategies within your execution logic to manage potential errors or exceptions that might occur during execution.
  • Performance: Optimize the sequence and configuration of blocks to reduce latency and improve the efficiency of the workflow, particularly when a workflow is customer facing.