@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
- setStaticCacheAdapter
- getAiAgentDetails
- getAiAgentSession
- getPortalDetails
- getConnectedApps
- getPreviousTranscript
- getMaskingPatterns
- getMyPortals
- getAgentsByPortal
- getUserProfiles
- selectUserProfile
- clearCache
- invalidateCache
- getUserDetails
- getCustomerDetails
- getDeploymentInfo
- clearDeploymentInfoCache
Constructors
constructor
• new ApiHelper(config): ApiHelper
Parameters
| Name | Type |
|---|---|
config | ApiHelperConfig |
Returns
Defined in
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
| Name | Type | Description |
|---|---|---|
adapter | CacheAdapter | Custom CacheAdapter implementation |
Returns
void
Defined in
getAiAgentDetails
▸ getAiAgentDetails(options): Promise<any>
Gets the AI Agent details
Parameters
| Name | Type | Description |
|---|---|---|
options | GetAiAgentDetailsOptions | The options for the API call |
Returns
Promise<any>
The AI Agent details
Defined in
getAiAgentSession
▸ getAiAgentSession(options): Promise<string>
Gets the AI Agent session
Parameters
| Name | Type | Description |
|---|---|---|
options | GetAiAgentSessionOptions | The options for the API call |
Returns
Promise<string>
The AI Agent session ID
Defined in
getPortalDetails
▸ getPortalDetails(options): Promise<any>
Gets the portal details
Parameters
| Name | Type | Description |
|---|---|---|
options | GetPortalDetailsOptions | The options for the API call |
Returns
Promise<any>
The portal details
Defined in
getConnectedApps
▸ getConnectedApps(options): Promise<any>
Gets the connected apps
Parameters
| Name | Type | Description |
|---|---|---|
options | GetConnectedAppsOptions | The options for the API call |
Returns
Promise<any>
The connected apps
Defined in
getPreviousTranscript
▸ getPreviousTranscript(options): Promise<any[]>
Gets the previous transcript
Parameters
| Name | Type | Description |
|---|---|---|
options | GetPreviousTranscriptOptions | The options for the API call |
Returns
Promise<any[]>
The previous transcript messages
Defined in
getMaskingPatterns
▸ getMaskingPatterns(options): Promise<any>
Gets the masking patterns for a department and channel
Parameters
| Name | Type | Description |
|---|---|---|
options | GetMaskingPatternsOptions | The options for the API call |
Returns
Promise<any>
The masking patterns response
Throws
If the API request fails
Defined in
getMyPortals
▸ getMyPortals(options): Promise<any[]>
Gets portals for the authenticated user via GET .../knowledge/portalmgr/v3/myportals (paginated).
Parameters
| Name | Type | Description |
|---|---|---|
options | GetMyPortalsOptions | Options for the API call |
Returns
Promise<any[]>
Promise resolving to array of Portal objects
Throws
Error if the API request fails
Example
const portals = await apiHelper.getMyPortals({
authToken: token,
language: 'en-us',
userId: 'user-123'
});Defined in
getAgentsByPortal
▸ getAgentsByPortal(options): Promise<any[]>
Gets AI agents by portal and department.
Parameters
| Name | Type | Description |
|---|---|---|
options | GetAgentsByPortalOptions | Options for the API call |
Returns
Promise<any[]>
Promise resolving to array of agent list items
Throws
Error if the API request fails
Example
const agents = await apiHelper.getAgentsByPortal({
departmentId: department.id,
portalId: portal.id,
agentType: 'contact-center',
authToken: token
});Defined in
getUserProfiles
▸ getUserProfiles(options): Promise<any[]>
Gets user profiles for a portal.
Parameters
| Name | Type | Description |
|---|---|---|
options | GetUserProfilesOptions | Options for the API call |
Returns
Promise<any[]>
Promise resolving to array of UserProfile objects
Throws
Error if the API request fails
Example
const profiles = await apiHelper.getUserProfiles({
portalId: portal.id,
authToken: token
});Defined in
selectUserProfile
▸ selectUserProfile(options): Promise<void>
Selects a user profile for a portal. Persists the selection on the server.
Parameters
| Name | Type | Description |
|---|---|---|
options | SelectUserProfileOptions | Options for the API call |
Returns
Promise<void>
Promise resolving when selection is complete
Throws
Error if the API request fails
Example
await apiHelper.selectUserProfile({
portalId: portal.id,
profileId: profile.id,
authToken: token
});Defined in
clearCache
▸ clearCache(): void
Clears all cached entries for this ApiHelper instance
Returns
void
Defined in
invalidateCache
▸ invalidateCache(pattern?): void
Invalidates cached entries matching a specific pattern or method name
Parameters
| Name | Type | Description |
|---|---|---|
pattern? | string | Optional pattern to match (e.g., 'getAiAgentDetails', 'getPortalDetails') If not provided, clears all cache entries for this instance |
Returns
void
Defined in
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
| Name | Type |
|---|---|
options | GetUserDetailsOptions |
Returns
Promise<null | UserDetails>
Defined in
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
| Name | Type |
|---|---|
options | GetCustomerDetailsOptions |
Returns
Promise<null | UserDetails>
Defined in
getDeploymentInfo
▸ getDeploymentInfo(domain): Promise<any>
Gets the deployment information for a given domain
Parameters
| Name | Type | Description |
|---|---|---|
domain | string | The domain to get the deployment information for |
Returns
Promise<any>
The deployment information
Defined in
clearDeploymentInfoCache
▸ clearDeploymentInfoCache(): void
Clears the static deployment info cache
Returns
void