Replay Active Calls on Refresh
When a rep refreshes the Salesforce page in the middle of a call, getActiveCalls() is called to restore the state of the VoiceCall record page and to attempt to replay the call with the same payload.
This section assumes that you’ve implemented the getActiveCalls() API in the connector.
For example, if an active call is refreshed while it’s connected, a CALL_CONNECTED event is replayed with the same call. If an active call is refreshed while it’s ringing, a CALL_STARTED event is replayed with the same call.
The getActiveCalls() method is implemented in the demo connector using JS local storage, but it’s best that you implement it on the server side rather than in local storage. We recommend storing the active calls in a server-side database as soon as a call starts, and updating the database on subsequent events. This way, Salesforce receives the most current data when getActiveCalls() is called.
In case you want to replay the calls yourself, we recommend that you set the isReplayable field in callInfo attribute of the call object to false so that the base connector doesn’t replay the calls when the rep becomes available.
1getActiveCalls() {
2 // Get the current calls in progress
3 const callsInProgress = getCallsInProgress();
4
5 // Create active calls and set isReplayable to false
6 const activeCalls = callsInProgress.map((call) => {
7 call.callInfo = new CallInfo({ isReplayable: false });
8 return new PhoneCall(call);
9 });
10
11 // Return the active calls back in ActiveCallsResult
12 const activeCallsResult = new ActiveCallsResult({ activeCalls });
13 return activeCallsResult;
14}
See Also