LogoLogo
Visit Contextual.ioSign Up
  • Getting Started
    • Welcome
    • Tour: Hello, AI World!
  • TRAINING
    • Basic Developer Training Course
      • Lesson 1: HTTP Agent Introduction
      • Lesson 2: Logging and Error Handling Basics
      • Lesson 3: Event Processing Agent Introduction
  • Services Catalog
    • What's in the Catalog?
      • Intro Patterns
      • Object Type Bundles
    • Browse by Platform
    • All Intro Patterns
      • Anthropic Claude Image Analysis
      • Mistral AI Prompt and Response
      • xAI Grok Prompt and Response
      • DeepSeek Chat Prompt and Response
      • Qwen Chat Prompt and Response
      • Perplexity AI Search and Response
      • Firecrawl Website Scraper
      • Groq Prompt and Response
      • Nyckel Dog Breed Classification
      • RapidAPI ClassifyAI Text Classification
      • RapidAPI YouTube AI Video Summary
      • UnifyAI Model Comparison
      • WebPilot URL Analysis and Summarization
      • OpenAI Assistants Prompt and Response
      • OpenAI Sync
    • All Prebuilt Solutions
      • Invoice AI
      • Lead Generation Form
    • All Object Type Bundles
      • Work Order Management System ITIL Object Type Bundle
        • Work Order
        • User
        • Role
        • Permission
        • Asset
        • Task
        • Action
        • Attachment
        • Comment
        • Notification
        • Audit Log
        • Service Level Agreement
        • Custom Fields
        • Work Order Template
        • Work Order Transition
        • Escalation Policy
        • Tag
  • Components & Data
    • Object Types
      • Data in Contextual
        • Secrets
        • Validation
        • Versioning
      • Examples
      • Creating an Object Type
      • Object Type Details
        • Definition
        • Data Schema
          • Automatic Record Metadata
          • Generated Values
            • Dates and Times
            • UUIDs
          • Frequently Used Validation
          • Disallowing Null Property Values
          • Disallowing Undefined Properties
          • Secrets
          • AI Assistant
          • ID and PrimaryKey Permanence
        • UI Schemas
        • Features
        • Triggers
        • Actions
        • Audit Trail
        • Versions
        • Templates
        • Records
      • Using Object Types in Flows
      • Records
        • Records and Your Tenant API
        • Record Import
    • Flows
      • Nodes
      • Wires
      • Message Object
      • Flow Editor
        • Basics
        • Saving Changes
        • In-Flow Testing with Debugger
        • Restart Agents to Make Changes Active
        • Config
      • Node Reference
        • Common
          • Log Tap
          • Inject
          • Debug
          • Complete
          • Catch
          • Status
          • Link In
          • Link Call
          • Link Out
          • Comment
        • Event
          • Prepare Event
          • Event Start
          • Event End
          • Event Error
        • Object
          • Search Object
          • Get Object
          • Create Object
          • Patch Object
          • Put Object
          • Delete Object
          • Run Action
        • Request
          • Send to Agent
          • HTTP GET
          • HTTP PATCH
          • HTTP PUT
          • HTTP DELETE
          • HTTP POST
          • GQL
          • Produce Message
        • Function
          • Function
          • Switch
          • Change
          • Range
          • Template
          • Delay
          • Trigger
          • Exec
          • Filter
          • Loop
        • Models
          • ML Predict
        • Network
          • MQTT In
          • MQTT Out
          • HTTP In
          • HTTP Response
          • HTTP Request
          • WebSocket In
          • WebSocket Out
          • TCP In
          • TCP Out
          • TCP Request
          • UDP In
          • UDP Out
        • Sequence
          • Split
          • Join
          • Sort
          • Batch
        • Parser
          • csv
          • html
          • json
          • xml
          • yaml
    • Agents
      • Creating an Agent
      • Types of Agents
        • Event to Flow
        • HTTP to Flow
          • Custom Domains
      • How Agents Work
        • Flow Execution
        • HTTP Load Balancing
        • Event Routing
      • Scale and Performance
        • Flow execution
        • Parallel Instances
        • Event Lag Scaling
        • Compute Threshold Scaling
        • Instance Compute Sizing
      • Agent Details
        • Definition
        • Operations
        • Logs
          • Session Log
          • Message Log
        • Audit Trail
        • Versions
      • Using Agents in Flows
    • Connections
      • Creating a Connection
      • Types of Connections
        • Basic
        • Bearer
        • Client Grant
        • Kafka
        • Password Grant
        • Public
        • Pulsar
      • Using Connections in Flows
    • JWKS Profiles
      • Using JWKS Profiles in Your Solution
  • PATTERNS
    • Solution Architecture
      • Events, Messages, Queues
    • Working with Data
      • Search Object Node & Pagination
      • Message Payload Content - Triggers and Actions
    • Industry Cookbooks
      • Field Services
  • Tenants
    • Tenant Workspace
    • Tenant Logs
      • Contextual Log Query Language (CLQL)
        • String Searches
        • Keyword Searches
        • Advanced Operators
    • Tenant API
      • API Keys
        • API Key Settings
        • API Key Permissions
      • Documentation
  • Release Notes
    • 2024
      • 2024.12.09
Powered by GitBook
On this page
  • Post-Insert Trigger Payload
  • Post-Update Trigger Payload
  • Post-Delete Trigger Payload
  • Action Payload
  • SendToAgent Payload

Was this helpful?

  1. PATTERNS
  2. Working with Data

Message Payload Content - Triggers and Actions

You can configure Triggers and Actions on your Object Types to pass a Record (an instance of the data) along to an Agent for processing.

  • Triggers - These are configured on Object Types and pass a new (post insert), updated (post-update) or deleted (post-delete) record along to the designated Agent for processing.

  • Actions - These can be manually run or triggered via API. To run an Action manually you configure the Action on the Object Type and then execute it in the overflow menu for the record itself.

Note that the format of a Trigger payload for a Record is slightly different than that for an Action.

On a Trigger the record is passed and directly available on msg.payload.

On an Action it will be under an instance property, so msg.event.instance.

For all of the examples below, we will use the following sample weather-report record:

{
    "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
    "datetime": "2024-09-19T12:13:11.435Z",
    "temperature": 25,
    "stationId": "JEFF"
}

Post-Insert Trigger Payload

A post-insert trigger payload delivered to an Event processing agent (flow) sets both msg.payload and msg.event to the same initial value

Shown below is the msg object with the properties received as a result of a Post-Insert trigger. Note that payload shows "circular" because it is the same as msg.event.

{
    "event": {
        "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
        "datetime": "2024-09-19T12:13:11.435Z",
        "temperature": 25,
        "stationId": "JEFF",
        "_metaData": {
            "createdAt": "2024-09-19T12:13:11.452Z",
            "hash":"a403d153ed381c1d05c191a8f0e8d1376e59037f5f73ae87d2e1b3214a9cf1be",
            "schema":"native-object:weather-report",
            "type":"custom",
            "updatedAt":"2024-09-19T12:13:11.452Z",
            "secrets":[]
        },
    },
    "payload": (circular),
    "topic": "persistent://project1/default/weather-monitor",
    "headers":{7 items
        "x-kind": ["trigger"]
        "x-log-correlation-id":["mhwRK4sMendQZtykKeEbJu"]
        "x-name":["Send New Weather Report"],
        "x-request-id":["pjqBvhPBMus1ttNJUiwEWK"],
        "x-subkind":["post-insert"],
        "x-type-id":["weather-report"],
        "x-uri":["native-object:weather-report/1LsZi8fwSWZsnx8LZ5Hsx5"]
    }
    "scriptUri":string"native-object:flow/weather-monitor#2"
}

In addition, note the various metaData, topic, and headers that provide additional context about the event being received, including the name of the object-type in the "x-type-id" header and the "x-kind" header which indicates that it was a "trigger" that sent the event. Finally the "x-subkind" header documents that it was a "post-insert" trigger.

Post-Update Trigger Payload

The msg object received by a post-update trigger has a different structure because it carries with it both the "old" and the "new" version of the record, as shown below:

{
    "event": {
        "new": {
            "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
            "datetime": "2024-09-19T15:15:15.350Z",
            "temperature": 27,
            "stationId": "JEFF",
            "_metaData": {
                "createdAt": "2024-09-19T12:13:11.452Z",
                "hash":"a403d153ed381c1d05c191a8f0e8d1376e59037f5f73ae87d2e1b3214a9cf1be",
                "schema":"native-object:weather-report",
                "type":"custom",
                "updatedAt":"2024-09-19T15:15:15.350Z",
                "secrets":[]
            },
        }
        "old": {
            "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
            "datetime": "2024-09-19T12:13:11.435Z",
            "temperature": 25,
            "stationId": "JEFF",
            "_metaData": {
                "createdAt": "2024-09-19T12:13:11.452Z",
                "hash":"a403d153ed381c1d05c191a8f0e8d1376e59037f5f73ae87d2e1b3214a9cf1be",
                "schema":"native-object:weather-report",
                "type":"custom",
                "updatedAt":"2024-09-19T12:13:11.452Z",
                "secrets":[]
            },
        }
    },
    "payload": (circular),
    "topic": "persistent://project1/default/weather-monitor",
    "headers":{7 items
        "x-kind": ["trigger"]
        "x-log-correlation-id":["mhwRK4sMendQZtykKeEbJu"]
        "x-name":["Send Updated Weather Report"],
        "x-request-id":["pjqBvhPBMus1ttNJUiwEWK"],
        "x-subkind":["post-update"],
        "x-type-id":["weather-report"],
        "x-uri":["native-object:weather-report/1LsZi8fwSWZsnx8LZ5Hsx5"]
    }
    "scriptUri":string"native-object:flow/weather-monitor#2"
}

Post-Delete Trigger Payload

The post-delete trigger payload looks basically the same as the post-insert with the exception of the headers:

{
    "event": {
        "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
        "datetime": "2024-09-19T12:13:11.435Z",
        "temperature": 25,
        "stationId": "JEFF",
        "_metaData": {
            "createdAt": "2024-09-19T12:13:11.452Z",
            "hash":"a403d153ed381c1d05c191a8f0e8d1376e59037f5f73ae87d2e1b3214a9cf1be",
            "schema":"native-object:weather-report",
            "type":"custom",
            "updatedAt":"2024-09-19T12:13:11.452Z",
            "secrets":[]
        },
    },
    "payload": (circular),
    "topic": "persistent://project1/default/weather-monitor",
    "headers":{7 items
        "x-kind": ["trigger"]
        "x-log-correlation-id":["mhwRK4sMendQZtykKeEbJu"]
        "x-name":["Send Deleted Weather Report"],
        "x-request-id":["pjqBvhPBMus1ttNJUiwEWK"],
        "x-subkind":["post-delete"],
        "x-type-id":["weather-report"],
        "x-uri":["native-object:weather-report/1LsZi8fwSWZsnx8LZ5Hsx5"]
    }
    "scriptUri":string"native-object:flow/weather-monitor#2"
}

Action Payload

An action is defined in object-type settings for a specific object-type and allows the user to invoke a specified action on an individual record. The action performs a SentToAgent to a specific agent, and the sample msg contents as shown below.

Note that the actual record contents in the case of action are in event.instance. This is because an action can also send “params” or parameters to the flow and these are passed in event.params.

Since the specific action-name is provided in the x-name header, a single flow/agent can be used to process multiple actions.

{
    "event": {
        "instance": {
            "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
            "datetime": "2024-09-19T12:13:11.435Z",
            "temperature": 25,
            "stationId": "JEFF",
            "_metaData": {
                "createdAt": "2024-09-19T12:13:11.452Z",
                "hash":"a403d153ed381c1d05c191a8f0e8d1376e59037f5f73ae87d2e1b3214a9cf1be",
                "schema":"native-object:weather-report",
                "type":"custom",
                "updatedAt":"2024-09-19T12:13:11.452Z",
                "secrets":[]
            },
        },
        "params: {}
    },
    "payload": (circular),
    "topic": "persistent://project1/default/weather-monitor",
    "headers":{7 items
        "x-kind": ["action"]
        "x-log-correlation-id":["mhwRK4sMendQZtykKeEbJu"]
        "x-name":["action-name"],
        "x-request-id":["pjqBvhPBMus1ttNJUiwEWK"],
        "x-subkind":["9bbc0dea-1a3c-4459-9320-2b55a1a0f142"],
        "x-type-id":["weather-report"],
        "x-uri":["native-object:weather-report/1LsZi8fwSWZsnx8LZ5Hsx5"]
    }
    "scriptUri":string"native-object:flow/weather-monitor#2"
}

SendToAgent Payload

The final use case is that of the event that is received when it is sent by a "SendToAgent" node in a flow.

Shown below is the msg object with the properties received as a result of a SendToAgent node. Note that payload shows "circular" because it is the same as msg.event.

{
    "event": {
        "id": "1LsZi8fwSWZsnx8LZ5Hsx5",
        "datetime": "2024-09-19T12:13:11.435Z",
        "temperature": 25,
        "stationId": "JEFF"
    },
    "payload": (circular),
    "topic": "persistent://project1/default/weather-monitor",
    "headers":{
    }
    "scriptUri":string"native-object:flow/weather-monitor#2"
}

Note that in this case the event/payload that is sent is literally whatever was sent by the sending agent using the SendToAgent node.

In this case there are no headers that are sent. This could change in the future.

PreviousSearch Object Node & PaginationNextIndustry Cookbooks

Last updated 7 months ago

Was this helpful?