How To Edit CAPTCHA Error Message in Auth0.js: "Error getting the bot detection challenge. Please contact the system administrator."
Last Updated:
Overview
This article explains how to customize the error message below, which is displayed when:
- Auth0.js is used to implement the login/signup screen
- And the library fails to load and present the Bot Detection UI
Error getting the bot detection challenge. Please contact the system administrator.
Applies To
- Bot Detection
- CAPTCHA
- Auth0.js
Cause
The error message is hardcoded in the default template defined in the library's source code. Giving the language option (e.g., lang: 'ja') will not change/localize this error message.
Solution
The error function in the template option parameter has to be edited.
var captcha = webAuth.renderCaptcha(
document.querySelector('.captcha-container'),
{
templates: {
// IMPORTANT!
// Customizing templates will overwrite the entire templates object.
// The template function for the successful path must be re-defined so that the Bot Detection in use keeps functioning even if no customization for this part is needed.
auth0_v2: function () {
return '<div class="auth0_v2" ></div><input type="hidden" name="captcha" />';
},
// Overwrite the error template.
error: function() {
return '<div class="error" style="color: red;">CUSTOMIZED/LOCALIZED MESSAGE</div>';
}
},
lang: 'ja'
},
(error, payload) => {
if (payload) {
triggerCaptcha = payload.triggerCaptcha;
}
}
);