@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
- getTranscript
- getInitParams
- getAgentDetails
- getMsalAccessToken
- getDeploymentInfo
- getPlatformType
- getEnvironment
- getUserId
- getUserContext
- getConversationId
- getAuthScopes
- getTenantId
- getSelectedPortal
- getCallerInfo
- addToTranscript
- setCallerInfo
- setPlatformAuthenticated
- setPlatformToken
- setConversationId
- setUserContext
- setUserFilterTags
- subscribeToAgentWidgetActions
- onUserMessage
- onSourceClick
- onIntentConfirm
Properties
getTranscript
• getTranscript: () => CallTranscriptEntry[]
Returns the current call transcript entries (telephony conversation, not AI chat).
Type declaration
▸ (): CallTranscriptEntry[]
Returns
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
| Name | Type |
|---|---|
entry | Object |
entry.sender | string |
entry.content | string |
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
| Name | Type |
|---|---|
callerInfo | CallerInfo |
Returns
void
Defined in
core/platform/HookContract.ts:101
setPlatformAuthenticated
• setPlatformAuthenticated: (value: boolean) => void
Mark the platform as authenticated.
Type declaration
▸ (value): void
Parameters
| Name | Type |
|---|---|
value | boolean |
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
| Name | Type |
|---|---|
token | string |
Returns
void
Defined in
core/platform/HookContract.ts:107
setConversationId
• setConversationId: (id: string) => void
Set the conversation/interaction ID.
Type declaration
▸ (id): void
Parameters
| Name | Type |
|---|---|
id | string |
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
| Name | Type |
|---|---|
userContext | Record<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
| Name | Type |
|---|---|
filterTags | Record<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
| Name | Type |
|---|---|
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
| Name | Type |
|---|---|
message | string |
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
| Name | Type |
|---|---|
source | Object |
source.id | string |
source.title | string |
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
| Name | Type |
|---|---|
intent | Object |
intent.id | string |
intent.intent | string |
intent.confidence | number |
Returns
void