Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If enabled for your account, you can create a custom rule that determines whether ContactWorld Vonage Contact Center records a call based on the outbound, or dialed, number.

The custom rule that you create takes precedence for individual calls over your default ContactWorld default Vonage Contact Center account settings. You can use this feature in various ways depending on how your Salesforce org is set up.

...

To automate outbound call recording, create a custom Apex class that implements the NVMContactWorldVCCCore.ICustomValueProvider ISelectCallRecording interface and defines the GetCustomValue GetIsCallRecordingRequired method. Your GetCustomValue method GetIsCallRecordingRequired method must describe the logic that determines whether or not to record the call for a given number , and return a String VCCCore.CallRecordingResult object that tells ContactWorld the tells Vonage Contact Center the outcome.

Note
When using this feature make sure that your default account configuration complies with any regional legislation.

To create the custom class, familiarize yourself with creating Apex classes in Salesforce. For information on creating Apex classes, see Salesforce help.

NVMContactWorldVCCCore.ICustomValueProvider ISelectCallRecording interface definition:

global interface ICustomValueProviderISelectCallRecording {

StringVCCCore.CallRecordingResult GetCustomValueGetIsCallRecordingRequired(String contextclickToDialJson);

}

The context contains clickToDialJson contains the outbound phone number in JSON format: {"outboundNumber":"4155551212"}. You do not need to provide context because ContactWorld clickToDialJson because Vonage Contact Center passes the value to the method for you when an agent initiates an outbound call. The GetCustomValue method  The GetIsCallRecordingRequired method in your class must return a String VCCCore.CallRecordingResult object.

Note

When creating your new class, you must declare both the class and the method as global so that the ContactWorld Vonage Contact Center managed package can access the class and invoke the method.

To get the outboundNumber from the contextclickToDialJson, use an Apex JSON parser as in the  getOutboundNumberFromJson method in our example. Future releases of ContactWorld Vonage Contact Center may add some extra attributes to the context, so if use any other method to get the outboundNumber (such as regular expressions or string splitting), your class may stop working.

When you have created your class, you must ensure that ContactWorld Vonage Contact Center uses the class. For information about configuring the class that ContactWorld Vonage Contact Center uses to automate call recording, see Configuring custom settings for optional Vonage Contact Center features in Salesforce.

ContactWorld Vonage Contact Center uses the value of values in the returned String CallRecordingResult object to determine whether or not to record the call:

ValueData TypeDescription
isRecordingRequiredBoolean
  • If the value of the String object is 'true', the call is recorded
  • If the value of the String object is 'false', the call is not recorded
  • If the value of the String object is any other value including null, the default account settings for recording calls

...

  • apply
isErrorBooleanIf true, isError indicates to Vonage that an error occurred in your custom code.
errorMessageStringIf isError is true, this string should contain a useful error message.

Constructors available on VCCCore.CallRecordingResult:

  • global CallRecordingResult(Boolean isRecordingRequired)

  • global CallRecordingResult(Boolean isError, String errorMessage)

If an error occurs when an agent makes a call that triggers the apex code, a message appears in the agent's ContactPad. This message alerts them that the default call recording settings for the account have been applied and suggests that they contact their system administrator.

Expand
titleExample 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 whether or not to record the call are stored in a Map object: Map<String,Boolean> called regionRules. The keys of the Map are the area codes and the Boolean values provide the decisions.

Code Block
languagejava
global class CallRecordingByAreaCode implements NVMContactWorldVCCCore.ICustomValueProviderISelectCallRecording{
     
    // 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 whether or not to record a call
    private static final Map<String,Boolean> regionRules = new Map<String,Boolean>{
        // Fresno, CA
        '209' => true,
        // Atlanta, GA
        '404' => false,
        // Chicago, IL
        '708' => true,
        // Boston, MA
        '978' => false           
    };
         
         
    // This method is your implementation of our interface
    global StringVCCCore.CallRecordingResult GetCustomValueGetIsCallRecordingRequired(String contextclickToDialJson);{
     
        Boolean decision = null;
        String outboundNumber = getOutboundNumberFromJson(contextclickToDialJson);
         
        String areaCode = getAreaCodeFromPhoneNumber(outboundNumber);       
        decision = regionRules.get(areaCode);
     
        return new StringVCCCore.valueOfCallRecordingResult(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;
    }
}


...