Skip to content

@egain/ai-agent-sdk API Reference - v0.2.3-beta.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:369

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


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


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


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


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


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


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


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


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). Responses are not cached (portal lists are always fetched fresh).

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,
  language: 'en-us',
  shortUrlTemplate: 'ombre',
});

Defined in

core/api/ApiHelper.ts:816


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


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


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


clearCache

clearCache(): void

Clears all cached entries for this ApiHelper instance

Returns

void

Defined in

core/api/ApiHelper.ts:1053


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


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


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


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


clearDeploymentInfoCache

clearDeploymentInfoCache(): void

Clears the static deployment info cache

Returns

void

Defined in

core/api/ApiHelper.ts:1190

Released under the MIT License.