Skip to content

Trigger Payload

Trigger callback payload types for Connector Namespace integration.

Classes

TriggerCallbackBody dataclass

TriggerCallbackBody(value: Optional[List[T]] = None)

Bases: Generic[T]

Inner body of the Connector Namespace trigger callback, containing the array of trigger items.

Deserialization handles both batch and single-item JSON shapes:

  • Batch (splitOn disabled): {"value": [...items...]}
  • Single-item (splitOn enabled): {...item properties...}

Both shapes are normalized into the value list.

Attributes

value class-attribute instance-attribute
value: Optional[List[T]] = None

The list of trigger items delivered by the connector trigger. Contains all items regardless of whether the callback arrived in batch or single-item shape. May be None when the source payload contained an explicit "value": null property (or a null body), so consumers should null-check before iterating.

Methods:

from_dict classmethod
from_dict(data: Optional[dict[str, Any]], item_parser: Optional[Callable[[dict[str, Any]], T]] = None) -> Optional[TriggerCallbackBody[T]]

Parse a dictionary into a TriggerCallbackBody, handling both batch and single-item shapes.

The Connector Namespace delivers trigger callbacks in two shapes depending on the trigger configuration's splitOn setting:

  • Batch (splitOn disabled): {"value": [...items...]}
  • Single-item (splitOn enabled): {...item properties...}

This method transparently normalizes both shapes into value as a list.

Parameters:

Name Type Description Default
data Optional[dict[str, Any]]

The dictionary to parse, or None.

required
item_parser Optional[Callable[[dict[str, Any]], T]]

Optional callable to convert each item dict to type T. If not provided, items are returned as-is (dict).

None

Returns:

Type Description
Optional[TriggerCallbackBody[T]]

A TriggerCallbackBody instance, or None if data is None.

Example
Batch shape

batch_data = {"value": [{"id": "1"}, {"id": "2"}]} body = TriggerCallbackBody.from_dict(batch_data) len(body.value) 2

Single-item shape

single_data = {"id": "1", "subject": "Test"} body = TriggerCallbackBody.from_dict(single_data) len(body.value) 1

TriggerCallbackPayload dataclass

TriggerCallbackPayload(body: Optional[TriggerCallbackBody[T]] = None)

Bases: Generic[T]

Envelope type for Connector Namespace trigger callback payloads.

The Connector Namespace delivers callbacks in two shapes depending on the trigger configuration's splitOn setting:

  • Batch (splitOn disabled): {"body": {"value": [...items...]}}
  • Single-item (splitOn enabled): {"body": {...item...}}

Use the :meth:from_dict factory method to parse payloads that handles both shapes transparently, always normalizing into body.value as a list.

Type parameter T is the connector-specific trigger item type (e.g., GraphClientReceiveMessage for Office 365 email triggers).

Attributes

body class-attribute instance-attribute
body: Optional[TriggerCallbackBody[T]] = None

The body envelope containing the trigger items.

Methods:

from_dict classmethod
from_dict(data: Optional[dict[str, Any]], item_parser: Optional[Callable[[dict[str, Any]], T]] = None) -> Optional[TriggerCallbackPayload[T]]

Parse a dictionary into a TriggerCallbackPayload, handling both batch and single-item shapes.

Parameters:

Name Type Description Default
data Optional[dict[str, Any]]

The dictionary to parse (typically from JSON), or None.

required
item_parser Optional[Callable[[dict[str, Any]], T]]

Optional callable to convert each item dict to type T. If not provided, items are returned as-is (dict).

None

Returns:

Type Description
Optional[TriggerCallbackPayload[T]]

A TriggerCallbackPayload instance, or None if data is None.

Example

import json

Batch shape payload

batch_json = '{"body": {"value": [{"id": "1"}]}}' payload = TriggerCallbackPayload.from_dict(json.loads(batch_json)) len(payload.body.value) 1

Single-item shape payload

single_json = '{"body": {"id": "1", "subject": "Test"}}' payload = TriggerCallbackPayload.from_dict(json.loads(single_json)) len(payload.body.value) 1