Skip to main content

How to define Activity Parameters in Python

Activity parameters are the function parameters of the function decorated with @activity.defn. These can be any data type Temporal can convert, including 'dataclasses' when properly type-annotated. Technically this can be multiple parameters, but Temporal strongly encourages a single dataclass parameter containing all input fields. For example:

@dataclass
class YourParams:
your_int_param: int
your_str_param: str


@activity.defn
async def your_activity(params: YourParams) -> None:
...