Skip to content

Commit

Permalink
feat(cc): getBuddyAgents improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bhabalan committed Oct 29, 2024
1 parent d1190de commit 7156ee3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 0 additions & 2 deletions docs/samples/contact-center/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ async function fetchBuddyAgents() {
}
}

// Modify doAgentLogin to show buddy agents box on successful login
function doAgentLogin() {
webex.cc.stationLogin({teamId: teamsDropdown.value, loginOption: agentDeviceType, dialNumber: dialNumber.value}).then((response) => {
console.log('Agent Logged in successfully', response);
Expand All @@ -177,7 +176,6 @@ function doAgentLogin() {
});
}

// Modify logoutAgent to hide buddy agents box on logout
function logoutAgent() {
webex.cc.stationLogout({logoutReason: 'logout'}).then((response) => {
console.log('Agent logged out successfully', response);
Expand Down
10 changes: 5 additions & 5 deletions packages/@webex/plugin-cc/src/cc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
WelcomeEvent,
STATION_LOGIN_TYPE,
GetBuddyAgentsOptions,
BUDDY_AGENT_MEDIA_TYPE,
} from './types';
import {READY, CC_FILE} from './constants';
import Agent from './features/Agent';
Expand Down Expand Up @@ -161,21 +162,20 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
}

/**
* @param options
* @param options - GetBuddyAgentsOptions
* @returns Promise<BuddyAgentsResponse>
* @throws Error
* @example
* const buddyAgents = await webex.cc.getBuddyAgents({
* agentProfileId: 'selfAgentProfileId',
* mediaType: 'telephony',
* state: 'Available',
* mediaType: BUDDY_AGENT_MEDIA_TYPE.TELEPHONY,
* state: BuddyAgentState.AVAILABLE,
* });
*/
public async getBuddyAgents({
options = {
agentProfileId: this.agentConfig.agentProfileId,
mediaType: 'telephony',
state: undefined,
mediaType: BUDDY_AGENT_MEDIA_TYPE.TELEPHONY,
},
}: {
options: GetBuddyAgentsOptions;
Expand Down
8 changes: 6 additions & 2 deletions packages/@webex/plugin-cc/src/services/HttpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ class HttpRequest {
Object.keys(payload).forEach((key) => payload[key] === undefined && delete payload[key]);

// Send the service request
const response = await this.webex.request({
const response: IHttpResponse = await this.webex.request({
service,
resource,
method,
body: payload,
});
const trackingid = response.headers.get('trackingid');

this.webex.logger.log(
`Service request sent successfully. Response: ${JSON.stringify(response)}`
`Service request sent successfully to ${service}/${resource} with payload: ${JSON.stringify(
payload
)}, Request TrackingID: ${trackingid}`
);

// Listen for the event
Expand Down
18 changes: 16 additions & 2 deletions packages/@webex/plugin-cc/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,22 @@ export interface SubscribeRequest {

export type EventResult = IAgentProfile;

export type BuddyAgentMediaType = 'telephony' | 'chat' | 'social' | 'email';
export type BuddyAgentState = 'Available' | 'Idle';
export const BUDDY_AGENT_MEDIA_TYPE = {
TELEPHONY: 'telephony',
CHAT: 'chat',
SOCIAL: 'social',
EMAIL: 'email',
} as const;

export type BuddyAgentMediaType = Enum<typeof BUDDY_AGENT_MEDIA_TYPE>;

export const BUDDY_AGENT_STATE = {
AVAILABLE: 'Available',
IDLE: 'Idle',
} as const;

export type BuddyAgentState = Enum<typeof BUDDY_AGENT_STATE>;

export type GetBuddyAgentsOptions = {
agentProfileId?: string;
mediaType: BuddyAgentMediaType;
Expand Down

0 comments on commit 7156ee3

Please sign in to comment.