Skip to content

@egain/ai-agent-sdk API Reference - v0.1.1 / HookContract

Interface: HookContract

Bidirectional contract between the SDK and a platform connector script.

Read-only getters return live state (not stale snapshots) because the implementation closes over the AiAgent instance.

Table of contents

Properties

Properties

getTranscript

getTranscript: () => CallTranscriptEntry[]

Returns the current call transcript entries (telephony conversation, not AI chat).

Type declaration

▸ (): CallTranscriptEntry[]

Returns

CallTranscriptEntry[]

Defined in

core/platform/HookContract.ts:49


getInitParams

getInitParams: () => Record<string, string>

Returns a shallow copy of the initialization parameters.

Type declaration

▸ (): Record<string, string>

Returns

Record<string, string>

Defined in

core/platform/HookContract.ts:52


getAgentDetails

getAgentDetails: () => any

Returns the agent details object.

Type declaration

▸ (): any

Returns

any

Defined in

core/platform/HookContract.ts:55


getMsalAccessToken

getMsalAccessToken: () => Promise<null | string>

Returns the current MSAL/auth access token.

Type declaration

▸ (): Promise<null | string>

Returns

Promise<null | string>

Defined in

core/platform/HookContract.ts:58


getDeploymentInfo

getDeploymentInfo: () => any

Returns the deployment info object.

Type declaration

▸ (): any

Returns

any

Defined in

core/platform/HookContract.ts:61


getPlatformType

getPlatformType: () => null | string

Returns the platform type string (e.g. "genesys").

Type declaration

▸ (): null | string

Returns

null | string

Defined in

core/platform/HookContract.ts:64


getEnvironment

getEnvironment: () => string

Returns the deployment environment ("dev" | "qa" | "prod").

Type declaration

▸ (): string

Returns

string

Defined in

core/platform/HookContract.ts:67


getUserId

getUserId: () => null | string

Returns the user ID from init params.

Type declaration

▸ (): null | string

Returns

null | string

Defined in

core/platform/HookContract.ts:70


getUserContext

getUserContext: () => null | Record<string, unknown>

Returns the user context object.

Type declaration

▸ (): null | Record<string, unknown>

Returns

null | Record<string, unknown>

Defined in

core/platform/HookContract.ts:73


getConversationId

getConversationId: () => null | string

Returns the conversation ID set by the connector.

Type declaration

▸ (): null | string

Returns

null | string

Defined in

core/platform/HookContract.ts:76


getAuthScopes

getAuthScopes: () => string[]

Returns effective OAuth resource scopes for the auth flow: after the platform connector runs, the merged list in config.scopes wins; otherwise non-empty initParams.scopes (comma-separated) overrides config.scopes, then defaults (including core.customermgr.read for customer when neither query nor config supplies scopes).

Type declaration

▸ (): string[]

Returns

string[]

Defined in

core/platform/HookContract.ts:84


getTenantId

getTenantId: () => null | string

Returns the tenant ID from deployment info.

Type declaration

▸ (): null | string

Returns

null | string

Defined in

core/platform/HookContract.ts:87


getSelectedPortal

getSelectedPortal: () => null | Portal

Returns the currently selected portal, or null before selection.

Type declaration

▸ (): null | Portal

Returns

null | Portal

Defined in

core/platform/HookContract.ts:90


getCallerInfo

getCallerInfo: () => null | CallerInfo

Returns the caller info set by the connector.

Type declaration

▸ (): null | CallerInfo

Returns

null | CallerInfo

Defined in

core/platform/HookContract.ts:93


addToTranscript

addToTranscript: (entry: { sender: string ; content: string ; timestamp?: Date }) => void

Add an entry to the call transcript (telephony conversation, not AI chat).

Type declaration

▸ (entry): void

Parameters
NameType
entryObject
entry.senderstring
entry.contentstring
entry.timestamp?Date
Returns

void

Defined in

core/platform/HookContract.ts:98


setCallerInfo

setCallerInfo: (callerInfo: CallerInfo) => void

Set caller information (e.g. from CTI integration).

Type declaration

▸ (callerInfo): void

Parameters
NameType
callerInfoCallerInfo
Returns

void

Defined in

core/platform/HookContract.ts:101


setPlatformAuthenticated

setPlatformAuthenticated: (value: boolean) => void

Mark the platform as authenticated.

Type declaration

▸ (value): void

Parameters
NameType
valueboolean
Returns

void

Defined in

core/platform/HookContract.ts:104


setPlatformToken

setPlatformToken: (token: string) => void

Store a secondary platform-specific token.

Type declaration

▸ (token): void

Parameters
NameType
tokenstring
Returns

void

Defined in

core/platform/HookContract.ts:107


setConversationId

setConversationId: (id: string) => void

Set the conversation/interaction ID.

Type declaration

▸ (id): void

Parameters
NameType
idstring
Returns

void

Defined in

core/platform/HookContract.ts:110


setUserContext

setUserContext: (userContext: Record<string, unknown>) => void

Append to the user context (merge, not overwrite).

Type declaration

▸ (userContext): void

Parameters
NameType
userContextRecord<string, unknown>
Returns

void

Defined in

core/platform/HookContract.ts:113


setUserFilterTags

setUserFilterTags: (filterTags: Record<string, string[]>) => void

Set filter tags for portal content filtering.

Type declaration

▸ (filterTags): void

Parameters
NameType
filterTagsRecord<string, string[]>
Returns

void

Defined in

core/platform/HookContract.ts:116


subscribeToAgentWidgetActions

subscribeToAgentWidgetActions: (callback: (action: string, data: unknown) => void) => () => void

Subscribe to agent widget actions. Returns an unsubscribe function.

Type declaration

▸ (callback): () => void

Parameters
NameType
callback(action: string, data: unknown) => void
Returns

fn

▸ (): void

Returns

void

Defined in

core/platform/HookContract.ts:121


onUserMessage

onUserMessage: (message: string) => void

Forward a user message through the SDK's send pipeline.

Type declaration

▸ (message): void

Parameters
NameType
messagestring
Returns

void

Defined in

core/platform/HookContract.ts:126


onSourceClick

onSourceClick: (source: { [key: string]: unknown; id: string ; title: string ; url?: string }) => void

Handle a source click from the connector.

Type declaration

▸ (source): void

Parameters
NameType
sourceObject
source.idstring
source.titlestring
source.url?string
Returns

void

Defined in

core/platform/HookContract.ts:129


onIntentConfirm

onIntentConfirm: (intent: { [key: string]: unknown; id: string ; intent: string ; confidence: number }) => void

Handle an intent confirmation from the connector.

Type declaration

▸ (intent): void

Parameters
NameType
intentObject
intent.idstring
intent.intentstring
intent.confidencenumber
Returns

void

Defined in

core/platform/HookContract.ts:132

Released under the MIT License.