この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

CTI システムへのエンゲージメントオブジェクトの統合

カスタマーサービス担当者 (CSR) がソフトフォンを使用した着信通話を受け入れる場合、その通話のエンゲージメントインタラクションレコードが作成されるように CTI アダプターを変更します。エンゲージメントインタラクションは、エンゲージメントデータモデルに含まれています。エンゲージメントデータモデルには、他にエンゲージメント出席者とエンゲージメントトピックの 2 つのオブジェクトがあります。これらのオブジェクトには、インタラクションの開始日時と終了日時、インタラクションの内容、出席者の詳細などが保存されます。

CTI アダプターの変更

ここでは、Open CTI デモアダプターを例に挙げて、必要な変更について説明します。エンゲージメントオブジェクトにアクセスするには、Engagement Connect API または sObject API を使用して、アダプターに同様の変更を加えます。

メモ

Engagement Connect API (REST または Apex) は、エンゲージメント出席者、エンゲージメントインタラクション、およびエンゲージメントトピックのレコードを作成、取得、および削除する方法を提供します。

Connect API を使用すると、3 つのエンゲージメントオブジェクトに対して 3 つの操作をすべて 1 回の API コールで実行できます。

メモ

また、sObject API を使用して、エンゲージメントオブジェクトで CRUD 操作を実行することもできます。
デモアダプターは、ソフトフォンを使用した通話の着信を受け入れると、Aura コンポーネントコードをトリガーします。accept リスナーを含んだ callInitiatedPanel.cmp が表示されます。
1<button class="slds-size--1-of-2 slds-button slds-button--brand"
2onclick="{!c.accept}">Accept</button>
同時に、イベントが発生し、callInitiatedPanelController.js ���ァイルの accept メソッドによって取得されます。
1accept : function(cmp, event, helper) {
2helper.renderConnectedPanel(cmp);
3},
このメソッドによって、ヘルパーで定義された [Connected (接続済み)] パネルが表示されます。このパネルには SoftphoneContactSearchController Apex クラスが含まれており、callInitiatedPanelHelper.js ファイルからコールされます。
1renderConnectedPanel : function(cmp){
2    var recordId = cmp.get('v.recordId');
3    var account = cmp.get('v.account');
4    var recparam=(recordId)?recordId:'UNKNOWN';
5    sforce.opencti.runApex({
6        apexClass : 'SoftphoneContactSearchController',
7        methodName : 'createEngagementInteraction',
8        methodParams : 'recordId='+recparam ,
9        callback : function(result) {
10            cmp.getEvent('editPanel').setParams({
11                label : 'Open CTI Softphone: ' + cmp.get('v.state')
12            }).fire();
13            if (result.success) {
14                sforce.opencti.screenPop({
15                    type : sforce.opencti.SCREENPOP_TYPE.SOBJECT,
16                    params : { recordId : result.returnValue.runApex }
17                });
18            } else {
19                throw new Error('Unable to make a call. Contact your admin.');
20            }
21            cmp.getEvent('renderPanel').setParams({
22                type : 'c:connectedPanel',
23                attributes : {
24                    showDialPad : false,
25                    recordId : recordId,
26                    engagementId : result.returnValue.runApex,
27                    callType : 'Inbound',
28                    account : account,
29                    recordName: cmp.get('v.recordName'),
30                    presence : cmp.get('v.presence')
31                }
32            }).fire();
33        }
34    });
35}
SoftphoneContactSearchController Apex クラスには createEngagementInteraction メソッドがあり、次の例のように Connect API を使用してエンゲージメントインタラクションレコードを作成します。
1// Create Engagement Interaction using connect API
2webService static String createEngagementInteraction(String recordId) {
3    system.debug('In create Engagement Interaction');
4    ConnectApi.EngagementInteractionCreateInput interactionInput = new
5ConnectApi.EngagementInteractionCreateInput();
6    interactionInput.communicationChannel = 'Voice Call';
7    interactionInput.attendeeVerified = false;
8    interactionInput.startDateTime =
9datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
10    interactionInput.status = 'New';
11    if(recordId !='UNKNOWN' ){
12        interactionInput.initiatingAttendeeId = recordId;
13        interactionInput.attendeeAuthenticated = true;
14    }
15    ConnectApi.EngagementsCreateInput containerInput = new
16ConnectApi.EngagementsCreateInput();
17    containerInput.engagementInteraction = interactionInput;
18    ConnectApi.EngagementsCreateOutput output =
19ConnectApi.EngagementContainerConnect.createEngagementInteraction(containerInput);
20    return output.engagementInteraction.id;
21}
Connect API を使用して、エンゲージメントインタラクションレコードと一緒にエンゲージメント出席者とエンゲージメントトピックレコードを作成する場合は、createEngagementInteraction メソッドの入力を変更します。次の例は、Connect API を使用してエンゲージメント出席者レコードを作成する方法を示しています。
1List<ConnectApi.EngagementAttendeeCreateInput> eaList = new
2List<ConnectApi.EngagementAttendeeCreateInput>();
3ConnectApi.EngagementAttendeeCreateInput internalAttendeeInput = new
4ConnectApi.EngagementAttendeeCreateInput();
5internalAttendeeInput.startDateTime =
6datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
7internalAttendeeInput.internalAttendeeId = UserInfo.getUserId();
8eaList.add(internalAttendeeInput);
9if(recordId !='UNKNOWN' ){
10    ConnectApi.EngagementAttendeeCreateInput externalAttendeeInput = new
11ConnectApi.EngagementAttendeeCreateInput();
12    externalAttendeeInput.startDateTime =
13datetime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
14    externalAttendeeInput.externalAttendeeId = recordId;
15    eaList.add(externalAttendeeInput);
16}
17interactionInput.engagementAttendees = eaList;

エンゲージメントの内部出席者のためのエンゲージメント出席者レコードは、エンゲージメントのインタラクションレコードが作成された後に自動的に作成されます。必要に応じて、[内部出席者レコードの自動作成] 組織設定をオフにして、エンゲージメント出席者レコードの自動作成を停止してください。

コールが終了すると、別の Aura コンポーネントコードがトリガーされます。
1<button aura:id="endcall" class="slds-size--1-of-2 slds-button slds-button--destructive" onclick="{!c.endCall}">End</button>
endCall リスナーは connectedPanelController.js ファイルの endCall メソッドを呼び出します。
1endCall: function(cmp, event, helper) {
2sforce.opencti.runApex({
3apexClass : 'SoftphoneContactSearchController',
4methodName : 'updateEngagementInteraction',
5methodParams : 'recordId=' + cmp.get('v.engagementId'),
6callback : function(result) {
7if (result.success) {
8} else {
9throw new Error(
10'Unable to update EI. Contact your admin.');
11}
12helper.logCall(cmp, function(response) {
13cmp.getEvent('renderPanel').setParams({
14type : 'c:phonePanel',
15toast : {'type': 'normal', 'message': 'Call was ended.'},
16attributes : { presence : cmp.get('v.presence')}
17}).fire();
18})
19var param = {callback:
20function(response) {
21if (response.success) {
22console.log('API method call executed successfully! returnValue:', response.returnValue);
23} else {
24console.error('Something went wrong! Errors:', response.errors);
25}
26}};
27sforce.opencti.refreshView(param);
28}
29});
30}

必要に応じて、エンゲージメントインタラクション、エンゲージメント出席者、エンゲージメントトピックのレコードを更新するメソッドを SoftphoneContactSearchController Apex クラスに追加します。

また、sObject API を使用して、エンゲージメントオブジェクトで CRUD 操作を実行することもできます。次の例は、sObject API を使用してエンゲージメント出席者またはエンゲージメントトピックレコードを作成する方法を示しています。
1//Create Engagement Attendee
2List<EngagementAttendee> eaList = new List<EngagementAttendee>();
3EngagementAttendee internalAttendeeInput = new EngagementAttendee();
4internalAttendeeInput.EngagementId = output.engagementInteraction.id;
5internalAttendeeInput.StartDateTime = datetime.now();
63
7Integrate Your CTI System with the Engagement Objects
8internalAttendeeInput.InternalAttendeeId = UserInfo.getUserId();
9eaList.add(internalAttendeeInput);
10insert eaList;
11System.debug('EI Created'+eaList.get(0).id);
12//Update Engagement Attendee
13EngagementAttendee internalAttendee=[select id from EngagementAttendee where
14EngagementId=:output.engagementInteraction.id];
15internalAttendee.EndDateTime = datetime.now();
16internalAttendee.IsVerified = true;
17internalAttendee.Role='Self';
18update internalAttendee;
19System.debug('EA updated'+internalAttendee.EndDateTime);
20//Create Engagement Topic
21List<EngagementTopic> topicList = new List<EngagementTopic>();
22EngagementTopic topic = new EngagementTopic();
23topic.EngagementId = output.engagementInteraction.id;
24topic.Name = 'Address Change';
25topicList.add(topic);
26insert topicList;
27System.debug('ET Created'+topicList.get(0).id);
28//Update Engagement Topic
29EngagementTopic engagementTopic = [select id from EngagementTopic where
30EngagementId=:output.engagementInteraction.id];
31engagementTopic.ProcessFailureReason = 'Job Shift';
32update engagementTopic;