ExternalOp
ref / conversations / ExternalOp
Specifies an external operation and how to serialize and deserialize its return and error values.
Methods
task
ts
task(ctx: OC): R | Promise<R>;
The external operation to perform.
Receives the current context object from the surrounding middleware. This gives the task access to sessions (if used) and other values that are not present inside the conversation.
beforeStore
ts
beforeStore(value: R): I | Promise<I>;
Converts a value returned from the task to an object that can safely be passed to JSON
.
afterLoad
ts
afterLoad(value: I): R | Promise<R>;
Restores the original value from the intermediate representation that before
generated.
beforeStoreError
ts
beforeStoreError(value: unknown): unknown | Promise<unknown>;
Converts an error thrown by the task to an object that can safely be passed to JSON
.
afterLoadError
ts
afterLoadError(value: unknown): unknown | Promise<unknown>;
Restores the original error from the intermediate representation that before
generated.