@egain/ai-agent-sdk API Reference - v0.1.1 / TokenRefreshHandler
Class: TokenRefreshHandler
Handler for stale or expired token messages Processes metadata messages indicating token refresh is required
Hierarchy
↳
TokenRefreshHandler
Table of contents
Constructors
Methods
Constructors
constructor
• new TokenRefreshHandler(options?): TokenRefreshHandler
Parameters
| Name | Type |
|---|---|
options? | TokenRefreshHandlerOptions |
Returns
Overrides
BaseMessageHandler.constructor
Defined in
core/message/handlers/TokenRefreshHandler.ts:31
Methods
canHandle
▸ canHandle(message): boolean
Check if this handler can process the given message.
This method is called for each incoming message. Return true if this handler should process the message, false otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The incoming message to check |
Returns
boolean
true if this handler can process the message
Example
canHandle(message: Message): boolean {
// Handle only customer messages
return message.persona === 'customer';
}Overrides
Defined in
core/message/handlers/TokenRefreshHandler.ts:37
handle
▸ handle(message): Promise<MessageHandlerResult>
Process the message.
Called when canHandle returns true. Implement your message processing logic here. Can be synchronous or asynchronous.
Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message to process |
Returns
Promise<MessageHandlerResult>
Handler result or Promise resolving to result
Example
handle(message: Message): MessageHandlerResult {
return {
type: 'processed',
message,
timestamp: Date.now()
};
}Example
async handle(message: Message): Promise<MessageHandlerResult> {
await saveToDatabase(message);
return {
type: 'saved',
message,
timestamp: Date.now()
};
}