Context

The Workflow Context in the CXFabric platform is a tool that uses a JSON structure to manage and track data and the state of workflows from start to finish. It acts like a detailed diary, recording all activities and changes as the workflow progresses. This allows you to easily monitor the workflow, ensuring everything runs smoothly and supports dynamic, stateful application development.

Initial Context Setup

When a workflow starts, it is given a "default context." Think of this as a starting checklist that tells the workflow what it needs to know right from the beginning. This checklist is a JSON object, which is just a way of organizing information that computers can easily read and update. The default context makes sure everything is set up correctly from the start.

Dynamic Context Updates

As the workflow runs, the context is constantly updated. Imagine it as a real-time diary that notes down what each part of the workflow is doing. These updates help keep track of:

  • Ongoing Tasks: What’s currently happening.

  • Completed Tasks: What’s been done and the result.

  • Workflow Path: The route the workflow takes, which is useful for tracking progress and identifying any issues.

  • Errors and Exceptions: Problems that occur and where they happened, making it easier to fix them.

These updates make it easier to see how the workflow is progressing and find any issues if they come up.

Data Structuring and Management

The workflow context can handle different types of data, such as:

  • Metadata: Information about the data, like who created it and when.

  • Settings: Configuration options for different parts of the workflow.

  • Variables: Values that might change during the workflow.

  • Execution Steps: Detailed steps and actions taken by the workflow.

All this data is stored in a flexible way, allowing it to be easily saved and retrieved whenever needed.

Context Accessibility and Manipulation

Different parts of the workflow can access and change the context. This makes it easy for different components (like tiny apps within the workflow) to work together and share information:

  • Component Level: Individual parts can access data specific to them.

  • Flow Level: The entire workflow can see and use shared data.

  • Global Level: Some data might be accessible across different workflows.

The context is secured to prevent unauthorized changes, ensuring only the right parts of the workflow can make updates.

Version Control and Replay Functionality

The Workflow Context uses version control to keep track of every important change:

  • Versioning: Every time something significant happens in the workflow, a new version of the context is saved. This makes it possible to see how the workflow has evolved over time.

  • Replay Functionality: You can restart the workflow from any saved version, which is helpful for debugging and testing. If something goes wrong, you can start from the last successful step instead of starting over from the beginning.

Persistence and Security

After the workflow is done, you can save the context based on specific settings. This means you can look at the data later for analysis, reporting, or compliance checks.

Data Encryption: Sensitive data is encrypted both when it is stored and when it is being sent to keep it safe from unauthorized access.

Example Use Case

To understand how the workflow context works, let's look at an example. Suppose we create an automation workflow to connect to a Contact Center using a webhook. This workflow receives notifications for specific events and processes them based on their type.

Workflow Description and Initial Setup

  1. Workflow Initiation: The workflow starts with an empty context object {}.

  2. Webhook Component: The webhook receives notifications from a Contact Center and adds the event data to the context.

  3. Conditional/Selection Components: The workflow checks the type of event and routes it to the right processing branch.

  4. SQL Component: If the event type is "lookup customer with accountID," the SQL component is triggered to query a database for customer data and updates the context with the results.

Versioning the Workflow Context

The context is versioned at key points to capture its state:

  • Initial State: When the workflow starts.

  • Post-Event Reception: After receiving data from the webhook.

  • Post-Conditional Logic: After evaluating conditions and before executing branch logic.

  • Post-SQL Query: After retrieving and adding SQL query results to the context.

Example Versioning Flow

  1. Workflow Start: The workflow starts with an empty context {}.

    • Version 1: The initial state is captured and stored.

  2. Webhook Event Received: The webhook component receives an event and updates the context, e.g., { "eventType": "lookupCustomer", "accountID": "12345" }.

    • Version 2: This updated state is saved immediately after the webhook updates the context.

  3. Conditional Logic Processed: The workflow checks the eventType and decides on the execution path.

    • Version 3: Before executing the SQL component, the decision and any intermediate data modifications are captured.

  4. SQL Query Execution: The SQL component queries the database using accountID and updates the context with customer details, e.g., { "eventType": "lookupCustomer", "accountID": "12345", "customerName": "John Doe", "customerStatus": "Active" }.

    • Version 4: After the SQL query results are added to the context.

By using the Workflow Context Store, the CXFabric platform ensures that workflows are efficient, traceable, and secure, providing a powerful tool for managing complex automation tasks.

Last updated