Skip to content

Define an outbound connector

Outbound connectors are defined as classes derived from OutboundConnector. Bellow is a code of a simple connector that logs messages to console and returns a StatusModel object.

Tip

Connectors don't have to return a BaseModel. dict or simple types like str, int or float work as well.

from pydantic import BaseModel, Field
from loguru import logger

from python_camunda_sdk import OutboundConnector


class StatusModel(BaseModel):
    status: str


class LogConnector(OutboundConnector):
    message: str = Field(description="Message to log")

    async def run(self) -> StatusModel:
        logger.info(f"LogConnector: {self.message}")

        return StatusModel(status="ok")

    class ConnectorConfig:
        name = "LogConnector"
        type = "log"
from .log import LogConnector

Fields on the connector class define inputs to the connector.

Tip

Using Field is optional but it is recommended to set description as it will be used for template generation.

The ConnectorConfig class defines the name of the connector and its type. Both must be specified are used to generate template.

Finally, the logic of the connector is defined in a run method. Make sure you annotate the return type.

Warning

If run returns nothing, make sure you annotate it with async def run(self) -> None.