Genesysでの着信コールの受け入れ
メディア・ツールバー・アプリケーションは、マイクロサービスから公開された様々なイベントをリスニングします。
- メディア・ツールバー・アプリケーションから。
- Fusionアプリケーションから。
- Genesys用に構成されたソフト・フォンから。
次のフロー図は、エージェントがメディア・ツールバーまたはFusionアプリケーションからの着信コールを受け入れると実行される一連の操作を示しています:
シナリオ1および2: メディア・ツールバーおよびFusionアプリケーションからのコールを受け入れます
- エージェントは、Fusionアプリケーションまたはメディア・ツールバー・アプリケーションからコールを受け入れることができます。 エージェントがFusionアプリケーションの「回答」ボタンをクリックすると、
onToolbarInteractionCommand
イベントがコマンドaccept
で起動されます。 エージェントがメディア・ツールバー・アプリケーションからのコールを受け入れると、コールが受け入れられることがマイクロサービスに通知されます。 - メディア・ツールバー・アプリケーションは、このイベントを受信し、イベントがコールを受け入れる場合は、コールを受け入れるようにマイクロサービスに通知されます。
- マイクロサービスは、この通知を受信すると、
com.genesyslab.platform.voice.protocol.tserver.requests.party.RequestAnswerCall
リクエストを使用してコールを受け入れるようにGenesysサーバーにリクエストします。 RequestAnswerCall
リクエストが成功すると、EventEstablished
メッセージがGenesysからマイクロサービスを介してメディア・ツールバー・アプリケーションに伝播されます。- メディア・ツールバー・アプリケーションは、webソケットを介して
EventEstablished
メッセージを受信し、startCommEvent
アクションを起動します。 - Fusionアプリケーションでこのアクションが識別されると、一致した担当者およびエンゲージメント・パネルは、画面ポップのFusion構成管理で構成されたルールに基づいて開きます。
エージェントは、Fusionまたはメディア・ツールバー・アプリケーションからのコールを受け入れます
着信コール通知は、メディア・ツールバーおよびFusionアプリケーションに表示されます。 電話に応答するには、どこからでも受け付けます。
マイクロサービスにコールを受け入れるよう通知
エージェントがメディア・ツールバー・アプリケーションまたはFusionアプリケーションからのコールに応答すると、エージェントがコールを受け入れたことがマイクロサービスに通知されます。 これを有効にするには、次の例に示すように、vendorHandler.ts
ファイルのacceptCall
関数を更新する必要があります:
public async acceptCall(): Promise<void> {
const headers: Headers = (new Headers()) as Headers;
headers.set('Content-type', 'application/json');
const message: any = {
"type": "Accept",
"connectionId": VendorHandler.connectionId
};
const request: Request = new Request(`${VendorHandler.REST_ENDPOINT_URL}`, {
method: 'POST',
headers: headers,
body: JSON.stringify(message)
}) as Request;
await fetch(request);
}
マイクロサービスによるコールの受入れリクエストの作成
マイクロサービスは、PSDK
を使用して、コールに応答するリクエストを作成します。
マイクロサービスはEventEstablishedメッセージを受信
コールに応答するリクエストが成功すると、GenesysサーバーはEventEstablished
メッセージで応答します。このメッセージは、マイクロサービスを介してメディア・ツールバー・アプリケーションに伝播されます。
メディア・ツールバー・アプリケーションからstartCommEventをコール
webソケットを介してEventEstablished
メッセージを受信すると、次の例に示すように、callAcceptedHandler
ファンクションがintegrationEventsHandler.ts
ファイルからコールされます:
public webSocketOnMessage(event: MessageEvent): void {
const jsonMessage = JSON.parse(event.data);
console.log(jsonMessage);
if (jsonMessage.eventName === "EventRegistered") {
// Genesys notifies that the agent is ready
this.integrationEventsHandler.makeAgentAvailable();
} else if (jsonMessage.eventName === "EventRinging") {
// Show incoming call notification
this.integrationEventsHandler.incomingCallHandler(jsonMessage.ANI, jsonMessage.eventId);
VendorHandler.connectionId = jsonMessage.connectionId;
} else if (jsonMessage.eventName === "EventEstablished") {
// Genesys notifies that the call is accepted
this.integrationEventsHandler.callAcceptedHandler(jsonMessage.eventId);
} else if (jsonMessage.eventName === "EventReleased") {
// Genesys notifies that the call is disconnected
}
console.log("Message is received");
}
コールがFusionアプリケーションで受け入れられます
Fusionアプリケーションでは、コールが受け入れられ、メディア・ツールバー・アプリケーションUIが更新されたことが示されます。
シナリオ3: ソフト・フォンからの通話を受け入れる
エージェントがソフト・フォンからのコールを受け入れると、EventEstablished
イベントによって通知が送信され、受け入れられます。 EventEstablished
イベントでコール受入済シナリオを処理するロジックを追加できます。
次のフロー図は、エージェントがソフト・フォンからの着信コールを受け入れると実行される一連の操作を示しています:
- エージェントがソフト・フォン・アプリケーションからのコールを受け入れると、そのコールを受け入れるようにGenesysサーバーに通知され、コールが成功すると、Genesysサーバーは
EventEstablished
メッセージをマイクロサービスに送信し、マイクロサービスはwebソケットを介してこのメッセージをメディア・ツールバー・アプリケーションに伝播します。 - メディア・ツールバー・アプリケーションは、このイベントを受信し、
startCommEvent
アクションを起動します。 - Fusionアプリケーションでこのアクションが識別されると、一致した担当者とエンゲージメント・パネルは、スクリーン・ポップのFusion構成管理で構成されたルールに基づいて開きます。
マイクロサービスは、EventEstablishedメッセージをメディア・ツールバー・アプリケーションに伝播
エージェントがソフト・フォン・アプリケーションからのコールを受け入れると、そのコールを受け入れるようにGenesysサーバーに通知され、コールが受け入れられると、GenesysサーバーはEventEstablished
メッセージをマイクロサービスに送信し、マイクロサービスはwebソケットを介してこのメッセージをメディア・ツールバー・アプリケーションに伝播します。
メディア・ツールバー・アプリケーションからstartCommEventをコール
webソケットを介してEventEstablished
メッセージを受信すると、次の例に示すように、callAcceptedHandler
ファンクションがintegrationEventsHandler.ts
ファイルからコールされます:
public webSocketOnMessage(event: MessageEvent): void {
const jsonMessage = JSON.parse(event.data);
console.log(jsonMessage);
if (jsonMessage.eventName === "EventRegistered") {
// Genesys notifies that the agent is ready
this.integrationEventsHandler.makeAgentAvailable();
} else if (jsonMessage.eventName === "EventRinging") {
// Show incoming call notification
this.integrationEventsHandler.incomingCallHandler(jsonMessage.ANI, jsonMessage.eventId);
VendorHandler.connectionId = jsonMessage.connectionId;
} else if (jsonMessage.eventName === "EventEstablished") {
// Genesys notifies that the call is accepted
this.integrationEventsHandler.callAcceptedHandler(jsonMessage.eventId);
} else if (jsonMessage.eventName === "EventReleased") {
// Genesys notifies that the call is disconnected
}
console.log("Message is received");
}
コールがFusionアプリケーションで受け入れられます
Fusionアプリケーションでは、コールが受け入れられ、メディア・ツールバー・アプリケーションUIが更新されます。
完了コード
着信コールを受け入れるためのvendorHandler.ts
ファイルの完全なコードを次に示します。
import { ICtiVendorHandler } from './ICtiVendorHandler';
import { IntegrationEventsHandler } from '../integrationEventsHandler';
export class VendorHandler implements ICtiVendorHandler {
public static connectionId: string;
private static REST_ENDPOINT_URL: string = 'http://localhost:8087/genesys/events';
private static WS_ENDPOINT_URL: string = 'ws://localhost:8087/genesysWs';
private integrationEventsHandler: IntegrationEventsHandler;
constructor(integrationEventsHandler: IntegrationEventsHandler) {
this.integrationEventsHandler = integrationEventsHandler;
}
public async webSocketOnOpenHandler(): Promise<void> {
console.log("WebSocket opened");
const headers: Headers = (new Headers()) as Headers;
headers.set('Content-type', 'application/json');
const message: any = {
"type": "initialize"
};
const request: Request = new Request(`${VendorHandler.REST_ENDPOINT_URL}`, {
method: 'POST',
headers: headers,
body: JSON.stringify(message)
}) as Request;
await fetch(request);
}
public webSocketErrorHandler(error: any): void {
console.log("WebSocket error", error);
}
public webSocketCloseHandler(event: Event): void {
console.log("WebSocket is closed", event);
}
public webSocketOnMessage(event: MessageEvent): void {
const jsonMessage = JSON.parse(event.data);
console.log(jsonMessage);
if (jsonMessage.eventName === "EventRegistered") {
// Genesys notifies that the agent is ready
this.integrationEventsHandler.makeAgentAvailable();
} else if (jsonMessage.eventName === "EventRinging") {
// Show incoming call notification
this.integrationEventsHandler.incomingCallHandler(jsonMessage.ANI, jsonMessage.eventId);
VendorHandler.connectionId = jsonMessage.connectionId;
} else if (jsonMessage.eventName === "EventEstablished") {
// Genesys notifies that the call is accepted
this.integrationEventsHandler.callAcceptedHandler(jsonMessage.eventId);
VendorHandler.connectionId = jsonMessage.connectionId;
} else if (jsonMessage.eventName === "EventReleased") {
// Genesys notifies that the call is disconnected
}
console.log("Message is received");
}
public async makeAgentAvailable(): Promise<void> {
let webSocket: WebSocket = new WebSocket(`${VendorHandler.WS_ENDPOINT_URL}`);
webSocket.onopen = this.webSocketOnOpenHandler.bind(this);
webSocket.onmessage = this.webSocketOnMessage.bind(this);
webSocket.onclose = this.webSocketCloseHandler.bind(this);
webSocket.onerror = this.webSocketErrorHandler.bind(this);
}
public async makeAgentUnavailable(): Promise<void> {
// TODO: call the vendor specific api to make the agent available
}
public async makeOutboundCall(phoneNumber: string, eventId: string): Promise<void> {
// TODO: call the vendor specific api to make the make an outbound call
}
public async acceptCall(): Promise<void> {
const headers: Headers = (new Headers()) as Headers;
headers.set('Content-type', 'application/json');
const message: any = {
"type": "Accept",
"connectionId": VendorHandler.connectionId
};
const request: Request = new Request(`${VendorHandler.REST_ENDPOINT_URL}`, {
method: 'POST',
headers: headers,
body: JSON.stringify(message)
}) as Request;
await fetch(request);
}
public async rejectCall(): Promise<void> {
// TODO: call the vendor specific api to reject a call
}
public async hangupCall(): Promise<void> {
// TODO: call the vendor specific api to hangup a call
}
}
進捗の確認
これらのステップが終了したら、OJETサーバーを使用してアプリケーションを起動し、Fusionアプリケーションにサインインします。 メディア・ツールバーを開き、「エージェント可用性」ボタンをクリックしてエージェントをコールに使用できるようにします。 次に、カスタマ・ケア番号へのコールを開始します。 着信コール通知は、メディア・ツールバー・アプリケーションおよびFusionアプリケーション・ウィンドウで受信します。 メディア・ツールバー・アプリケーションから、またはFusionアプリケーションから、またはSoftphoneアプリケーションからコールを受け入れることができます。 コールを受け入れると、メディア・ツールバーの状態がACCEPTED状態に変わり、エンゲージメントがFusionアプリケーションで開きます。