Introduction:
As we already know, we can generate Cases from Email and Web using Email-to-Case and Web-to-Case respectively. Now in Spring 17, Salesforce introduces a feature to include reCAPTCHA in the web-to-case from. So that we can avoid spam cases. This change applies to both Lightning Experience and Salesforce Classic.
Steps to get Recaptcha key
Prerequisite: We need to have Google Account
- Sign in to your Google Account
- Go to the link, Recaptcha Link
- Click Get Recaptcha Button.
- Enter the Label
- Choose the type of Recaptcha, you want
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-950.png)
- Enter the domain where exactly your web to case form is hosted.
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-948.png)
- Check the “Accept the reCaptcha Terms of Service” checkbox.
- Click Register Button.
- Once the reCaptcha registration is done, a Site key and Secret key will be generated.
To generate the Web to Case form with “reCAPTCHA”,
- Go to Setup [Symbol] Build [Symbol] Customize [Symbol]Self-Service [Symbol] Web-to-Case[Symbol] Check “Enable Web-to-Case” check box.
- Go to Setup [Symbol] Build [Symbol] Customize [Symbol]Self-Service [Symbol] Web-to-Case HTML Generator
- Include the necessary fields which are need to be in the form.
- Check the Enable spam filtering (recommended) check box.
- Click on the lookup icon in reCAPTCHA API Key Pair.
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-946.png)
- Click the New Button.
- Provide the API Key Pair Nickname, Secret Key and Site Key which generated earlier.
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-949.png)
- Click the Save button.
- Click the Generate Button.
HTML Code for web-to-case form is generated with the script to generate reCAPTCHA. Now, we can move our web-to-case form to a Visualforce page by including the reCAPTCHA script.
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-947.png)
Client Side Integration
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-946.png)
We can validate if the user submits form without checking the reCaptcha check box by using script,
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-951.png)
![web to case recaptcha](https://www.mstsolutions.com/wp-content/uploads/2020/12/image-952.png)
Server Side Integration
For Server side Integration, we need to send a POST request to the URL, https://www.google.com/recaptcha/api/siteverify with the following parameters
Secret Key | Which is generated for your domain |
response | A part of payload with string name ‘g-recaptcha-response’ |
remoteIP | The end user’s IP Address |
Conclusion
Using reCaptcha, we can avoid spam Cases in Salesforce, so that customer service agents can focus on actual cases and not on the spam cases.
Reference Links: