Register an interceptor in Connect Customer agent workspace
Registers an asynchronous interceptor callback for the specified action key. When the UI triggers the action, your interceptor runs before the default behavior. If the same function is already registered for the same key and parameter, the call has no effect.
Signature
addInterceptor<T>( interceptorKey: InterceptorKey, interceptor: Interceptor<T>, options?: RegisterInterceptorOptions ): Promise<void> addInterceptor<T>( interceptorKey: InterceptorKey, interceptor: Interceptor<T>, parameter: string, options?: RegisterInterceptorOptions ): Promise<void>
Usage
// Without parameter await service.addInterceptor('clearContact', myInterceptor, { timeout: 5000 }); // With parameter (scoped to a specific contact) await service.addInterceptor('openQuickConnect', myInterceptor, contactId, { timeout: 5000 });
Input
The following table describes the input parameters.
| Parameter | Type | Description |
|---|---|---|
| interceptorKey Required | InterceptorKey (string) |
The action key to intercept. Valid values:
|
| interceptor Required | Interceptor<T> |
An asynchronous callback that receives a context object and returns
an InterceptorResult. See
Interceptor callback type in Connect Customer agent workspace. |
| parameter Optional | string | A scoping parameter. For the currently supported interceptor keys,
pass the contactId of the contact that the interceptor
applies to. If you omit this value, the interceptor applies to all contacts. |
| options Optional | RegisterInterceptorOptions |
The configuration options for this interceptor. If you omit this value, the service uses the default timeout of 5000 milliseconds and the default maximum consecutive block limit of 5. See RegisterInterceptorOptions in Connect Customer agent workspace. |
Output
Promise<void>
Contact scope:
Applies when you pass a parameter for one of the contact interceptor
keys (openQuickConnect, openOutboundDialer, or
clearContact). Requires an instance that is scoped to the contact that
you pass in parameter, or an instance without a contact scope. For
details, see Connect Customer SDK Contact API. A registration without a
parameter, or for any other key, has no contact scope
requirement.
Permissions required:
*