Web To Case has a provision by itself to gather customer support requests directly from the portal of any company and automatically generates up to 5,000 cases per day.

Introduction

Web To Case has a provision by itself to gather customer support requests directly from the portal of any company and automatically generates up to 5,000 cases per day. This helps organizations’ respond to customers faster, improving the support team’s productivity.

Business Problem

Organization has to design web forms for their customers to submit their cases. Moreover, there is an extra validation is needed to enable Spam filtering / refinement to avoid spam cases. A readily available tool can fix this problem and be of help for any Organization to be successful from day-1 for their Customers in this context.

Solution

Follow the below steps:

1. Register your domain in Google ReCaptcha Registration website and get the site key. For this, refer the link below and get the site key which will be used in the Visual Force Page. https://www.forcetalks.com/blog/step-by-step-procedure-to-implement-recaptcha-with-visualforce-page/

2. Copy the URL from the ReCaptcha Registration website and create the new remote site by searching for ‘Remote Site Settings’ in Quick find.

3. Create the visual force page(Code can be generated from the Web-to-Case HTML Generator) and the apex class.

Visual Force Page:

<apex:page standardController=”Case” extensions=”WebtoCaseControllerExt” lightningStylesheets=”true” sidebar=”false” showHeader=”false”>

<script src=’https://www.google.com/recaptcha/api.js’> </script>

<!— Include The Case Fields Here –>

<apex:commandButton value=”Submit” action=”{!createCaseWithAttachment}” />

<div class=”g-recaptcha slds-p-horizontal_medium ” data-sitekey=”enter your registered site key”></div>

</apex:page>

Apex Class:

public class WebtoCaseControllerExt {

public WebtoCaseControllerExt(ApexPages.StandardController stdController)

{

// Declare the Case object with a variable here

}

public PageReference createCaseWithAttachment() {

String reCAPTCHAStatus = ApexPages.CurrentPage().getParameters().get(‘g-recaptcha-response’);

if(String.isBlank(reCAPTCHAStatus))

{

ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,’Please enter ReCaptcha’));

return null;

}

else

{

// Insert the record into case object

}

//Create the web-to-case as an incoming email message and assign the case fields to the EmailMessage object’s fields

PageReference p = Page.WebToCase;

p.setRedirect(true);

return p;

}

}