Manage Interceptors - TypeScript SDK
Interceptors are a mechanism for modifying inbound and outbound SDK calls. Interceptors are commonly used to add tracing and authorization to the scheduling and execution of Workflows and Activities. You can compare these to "middleware" in other frameworks.
How to implement interceptors in TypeScript
The TypeScript SDK comes with an optional interceptor package that adds tracing with OpenTelemetry. See how to use it in the interceptors-opentelemetry code sample.
- WorkflowInboundCallsInterceptor: Intercept Workflow inbound calls like execution, Signals, and Queries.
- WorkflowOutboundCallsInterceptor: Intercept Workflow outbound calls to Temporal APIs like scheduling Activities and starting Timers.
- ActivityInboundCallsInterceptor: Intercept inbound calls to an Activity (such as
execute
). - WorkflowClientInterceptor: Intercept workflow-related methods of
Client
andWorkflowHandle
like starting or signaling a Workflow.
Interceptors are run in a chain, and all interceptors work similarly.
They accept two arguments: input
and next
, where next
calls the next interceptor in the chain.
All interceptor methods are optional—it's up to the implementor to choose which methods to intercept.