Issue with Passing Custom Data to Chatbot: CORS Error
I am trying to pass custom data from my website to the Chatbot, but I encounter a CORS error in the browser console. Below is the setup I have implemented:
Scripts Added to the Page<script>
window["chtlConfig"] = {
chatbotId: ***
};
</script>
<script
async
data-id="***"
id="chatling-embed-script"
type="text/javascript"
src="https://chatling.ai/js/embed.js">
</script>
After the script is loaded, I attempt to pass data to the Chatbot using the following code:window["Chatling"].setVariables(
{
contact_job_title: "1234"
},
function (success, errorMessage) {
if (!success) {
console.error("Error:", errorMessage);
} else {
console.log("Success");
}
}
);
When executing the above code, I get the following error in the browser console:
Access to fetch at 'https://chatling.ai/public/embed/chatbot/v2/chat/svv' from origin 'https://my.domain.com' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
The error suggests that the server is not allowing cross-origin requests from my domain.
Request for Assistance
Validation: Please let me know if there are any mistakes in my implementation.
Solution: How can I resolve this CORS error to successfully pass data to the Chatbot?
Thank you in advance for your support!
Log in to comment and vote
Comments1
Ali Mahdi
Dec 26, 2024
Hi, thanks for reporting this. The issue is now resolved.