Configuring automatic call recording for outbound calls using Apex with Vonage Premier for Service Cloud Voice

To automate call recording for Vonage Premier for Service Cloud Voice using Apex, follow the instructions in Automating call recording for outbound calls using Apex. In addition, you can choose which participants are recorded.

To choose which participants are recorded, use the VCCCore.CallRecordingResult constructor with the following signature:

  • global CallRecordingResult(Boolean isRecordingRequired, RecordingParticipant callRecordingParticipant)

This constructor returns a value for callRecordingParticipant in the CallRecordingResult object. Vonage uses callRecordingParticipant to determine which participants to record (if recording is required):

Value
Data Type
Description
callRecordingParticipantVCCCore.CallRecordingResult.RecordingParticipant

Determines which participants are included in the recording if the call is recorded.

  • AccountDefault — The default values for your account will be used.
  • All — All participants on the call will be included in the recording.
  • AgentsOnly — Only agent participants on the call will be included in the recording.
  • If the value is null, the default values for your account will be used.
 Example 1

In our example, the dialed number for the outbound call is supplied to the implementing class as the context parameter of the GetCustomValue method. The rules about which participants to record the call are stored in a Map object: Map<String,VCCCore.CallRecordingResult.RecordingParticipant> called regionRules. The keys of the Map are the area codes and the recording participant values to provide the decisions.

global class CallRecordingParticipantsByAreaCode implements VCCCore.ISelectCallRecording{
     
    // Build a regular expression to extract the area code from a full phone number   
    private static final String leftBracketPatternSegment = Pattern.quote('(');
    private static final String rightBracketPatternSegment = Pattern.quote(')');
    private static final String captureAreaCodePatternSegment = '([0-9]{3})';
    private static final String restOfPhoneNumberPatternSegment = '.*';
     
    private static final Pattern areaCodePattern = Pattern.compile(
            leftBracketPatternSegment +
            captureAreaCodePatternSegment +
            rightBracketPatternSegment +
            restOfPhoneNumberPatternSegment);
     
    // A map contains your rules for deciding which participants to include when recording a call
    private static final Map<String,VCCCore.CallRecordingResult.RecordingParticipant> regionRules = new Map<String,Boolean>{
        // Fresno, CA
        '209' => VCCCore.CallRecordingResult.RecordingParticipant.AgentsOnly,
        // Atlanta, GA
        '404' => VCCCore.CallRecordingResult.RecordingParticipant.All,
        // Chicago, IL
        '708' => VCCCore.CallRecordingResult.RecordingParticipant.All,
        // Boston, MA
        '978' => VCCCore.CallRecordingResult.RecordingParticipant.AccountDefault           
    };
         
         
    // This method is your implementation of our interface
    global VCCCore.CallRecordingResult GetIsCallRecordingRequired(String clickToDialJson);{
     
        VCCCore.CallRecordingResult.RecordingParticipant decision = null;
        String outboundNumber = getOutboundNumberFromJson(clickToDialJson);
         
        String areaCode = getAreaCodeFromPhoneNumber(outboundNumber);       
        decision = regionRules.get(areaCode);
     
        return new VCCCore.CallRecordingResult(true, decision);       
    }
    
    private static String getOutboundNumberFromJson(String context){
        Map<String, String> mapFromJson = (Map<String,String>)System.JSON.deserialize(context, Map<String,String>.class);
        String outboundNumber = mapFromJson.get('outboundNumber');
        System.debug(outboundNumber);
        return outboundNumber;
    }     
     
    private static String getAreaCodeFromPhoneNumber(String phoneNumber){
        String areaCode = null;     
        Matcher areaCodeMatcher = areaCodePattern.matcher(phoneNumber);
         
        if(areaCodeMatcher.matches()){
            areaCode = areaCodeMatcher.group(1);
            System.debug('area code: ' + areaCode);
        }
         
        return areaCode;
    }
}
Support and documentation feedback

For general assistance, please contact Customer Support.

For help using this documentation, please send an email to docs_feedback@vonage.com. We're happy to hear from you. Your contribution helps everyone at Vonage! Please include the name of the page in your email.