Skip to content

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

Class: ApiHelper

API Helper class for making eGain AI Agent API calls

Table of contents

Constructors

Methods

Constructors

constructor

new ApiHelper(config): ApiHelper

Parameters

NameType
configApiHelperConfig

Returns

ApiHelper

Defined in

core/api/ApiHelper.ts:357

Methods

setStaticCacheAdapter

setStaticCacheAdapter(adapter): void

Sets a custom static cache adapter for deployment info caching. Call this before any AiAgent.initialize() calls to use a custom adapter for caching deployment information.

Parameters

NameTypeDescription
adapterCacheAdapterCustom CacheAdapter implementation

Returns

void

Defined in

core/api/ApiHelper.ts:353


getAiAgentDetails

getAiAgentDetails(options): Promise<any>

Gets the AI Agent details

Parameters

NameTypeDescription
optionsGetAiAgentDetailsOptionsThe options for the API call

Returns

Promise<any>

The AI Agent details

Defined in

core/api/ApiHelper.ts:503


getAiAgentSession

getAiAgentSession(options): Promise<string>

Gets the AI Agent session

Parameters

NameTypeDescription
optionsGetAiAgentSessionOptionsThe options for the API call

Returns

Promise<string>

The AI Agent session ID

Defined in

core/api/ApiHelper.ts:541


getPortalDetails

getPortalDetails(options): Promise<any>

Gets the portal details

Parameters

NameTypeDescription
optionsGetPortalDetailsOptionsThe options for the API call

Returns

Promise<any>

The portal details

Defined in

core/api/ApiHelper.ts:568


getConnectedApps

getConnectedApps(options): Promise<any>

Gets the connected apps

Parameters

NameTypeDescription
optionsGetConnectedAppsOptionsThe options for the API call

Returns

Promise<any>

The connected apps

Defined in

core/api/ApiHelper.ts:615


getPreviousTranscript

getPreviousTranscript(options): Promise<any[]>

Gets the previous transcript

Parameters

NameTypeDescription
optionsGetPreviousTranscriptOptionsThe options for the API call

Returns

Promise<any[]>

The previous transcript messages

Defined in

core/api/ApiHelper.ts:654


getMaskingPatterns

getMaskingPatterns(options): Promise<any>

Gets the masking patterns for a department and channel

Parameters

NameTypeDescription
optionsGetMaskingPatternsOptionsThe options for the API call

Returns

Promise<any>

The masking patterns response

Throws

If the API request fails

Defined in

core/api/ApiHelper.ts:685


getMyPortals

getMyPortals(options): Promise<any[]>

Gets portals for the authenticated user via GET .../knowledge/portalmgr/v3/myportals (paginated).

Parameters

NameTypeDescription
optionsGetMyPortalsOptionsOptions for the API call

Returns

Promise<any[]>

Promise resolving to array of Portal objects

Throws

Error if the API request fails

Example

typescript
const portals = await apiHelper.getMyPortals({
  authToken: token,
  language: 'en-us',
  userId: 'user-123'
});

Defined in

core/api/ApiHelper.ts:742


getAgentsByPortal

getAgentsByPortal(options): Promise<any[]>

Gets AI agents by portal and department.

Parameters

NameTypeDescription
optionsGetAgentsByPortalOptionsOptions for the API call

Returns

Promise<any[]>

Promise resolving to array of agent list items

Throws

Error if the API request fails

Example

typescript
const agents = await apiHelper.getAgentsByPortal({
  departmentId: department.id,
  portalId: portal.id,
  agentType: 'contact-center',
  authToken: token
});

Defined in

core/api/ApiHelper.ts:851


getUserProfiles

getUserProfiles(options): Promise<any[]>

Gets user profiles for a portal.

Parameters

NameTypeDescription
optionsGetUserProfilesOptionsOptions for the API call

Returns

Promise<any[]>

Promise resolving to array of UserProfile objects

Throws

Error if the API request fails

Example

typescript
const profiles = await apiHelper.getUserProfiles({
  portalId: portal.id,
  authToken: token
});

Defined in

core/api/ApiHelper.ts:904


selectUserProfile

selectUserProfile(options): Promise<void>

Selects a user profile for a portal. Persists the selection on the server.

Parameters

NameTypeDescription
optionsSelectUserProfileOptionsOptions for the API call

Returns

Promise<void>

Promise resolving when selection is complete

Throws

Error if the API request fails

Example

typescript
await apiHelper.selectUserProfile({
  portalId: portal.id,
  profileId: profile.id,
  authToken: token
});

Defined in

core/api/ApiHelper.ts:960


clearCache

clearCache(): void

Clears all cached entries for this ApiHelper instance

Returns

void

Defined in

core/api/ApiHelper.ts:985


invalidateCache

invalidateCache(pattern?): void

Invalidates cached entries matching a specific pattern or method name

Parameters

NameTypeDescription
pattern?stringOptional pattern to match (e.g., 'getAiAgentDetails', 'getPortalDetails') If not provided, clears all cache entries for this instance

Returns

void

Defined in

core/api/ApiHelper.ts:996


getUserDetails

getUserDetails(options): Promise<null | UserDetails>

Fetches the authenticated user's details (for agent/user auth type). Returns null on failure so that initialization is not blocked.

Parameters

NameType
optionsGetUserDetailsOptions

Returns

Promise<null | UserDetails>

Defined in

core/api/ApiHelper.ts:1019


getCustomerDetails

getCustomerDetails(options): Promise<null | UserDetails>

Fetches the authenticated customer's details (for customer auth type). Returns null on failure so that initialization is not blocked.

Parameters

NameType
optionsGetCustomerDetailsOptions

Returns

Promise<null | UserDetails>

Defined in

core/api/ApiHelper.ts:1050


getDeploymentInfo

getDeploymentInfo(domain): Promise<any>

Gets the deployment information for a given domain

Parameters

NameTypeDescription
domainstringThe domain to get the deployment information for

Returns

Promise<any>

The deployment information

Defined in

core/api/ApiHelper.ts:1082


clearDeploymentInfoCache

clearDeploymentInfoCache(): void

Clears the static deployment info cache

Returns

void

Defined in

core/api/ApiHelper.ts:1122

Released under the MIT License.