Skip to content

@egain/ai-agent-sdk API Reference - v0.3.2 / 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:358

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:354


setLanguage ​

▸ setLanguage(language): void

Updates the default language for API calls (e.g. after agent details are loaded).

Parameters ​

NameType
languagestring

Returns ​

void

Defined in ​

core/api/ApiHelper.ts:387


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:511


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:549


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:594


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:641


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:680


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:711


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,
  userId: 'user-123'
});

Defined in ​

core/api/ApiHelper.ts:768


getPortals ​

▸ getPortals(options): Promise<any[]>

Gets all portals in the partition/department via GET .../knowledge/portalmgr/v3/portals (paginated). Used for customer and anonymous customer portal lists (Get All Portals API).

Parameters ​

NameTypeDescription
optionsGetPortalsOptionsOptions 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.getPortals({
  authToken: token,
  departmentId: 12,
});

Defined in ​

core/api/ApiHelper.ts:809


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:922


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:975


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:1031


clearCache ​

▸ clearCache(): void

Clears all cached entries for this ApiHelper instance

Returns ​

void

Defined in ​

core/api/ApiHelper.ts:1058


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:1069


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:1092


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:1123


getDeploymentInfo ​

▸ getDeploymentInfo(domain, cache?): Promise<any>

Gets the deployment information for a given domain

Parameters ​

NameTypeDescription
domainstringThe domain to get the deployment information for
cache?Pick<CacheConfig, "enabled">-

Returns ​

Promise<any>

The deployment information

Defined in ​

core/api/ApiHelper.ts:1155


clearDeploymentInfoCache ​

▸ clearDeploymentInfoCache(): void

Clears the static deployment info cache

Returns ​

void

Defined in ​

core/api/ApiHelper.ts:1195

Released under the MIT License.