This situation is simpler - just append the parameters directly to the URL without compression and encoding.
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Iframe Chatbot</title>
</head>
<body>
<h1>Iframe Chatbot</h1>
<script>
const inputs = {
"user_name": "Tom"
};
document.addEventListener('DOMContentLoaded', async () => {
const params = new URLSearchParams();
for (const [key, value] of Object.entries(inputs)) {
params.append(key, value);
}
const baseUrl = "http://localhost/chat/WMnzIe1JaO25EwIq";
const iframeUrl = `${baseUrl}?${params.toString()}`;
const iframe = document.createElement('iframe');
iframe.src = iframeUrl;
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.minHeight = '700px';
iframe.frameBorder = '0';
iframe.allow = 'microphone';
document.body.appendChild(iframe);
});
</script>
</body>
</html>