Jan
Jan5h ago

Automatically open chat widget

Hi All, is it possible to open the widget automatically if you use a specific link parameter for example "/?OpenChat=true". I don't want the widget to open every time just with a specific link which i can use for a qr code. Thanks for the help.
1 Reply
Tico | Voiceflow Assistant
Yep – you can do it with one small script. 1. Load the widget as usual with window.voiceflow.chat.load({...}). 2. Right after the load call, check the current URL for a query-string flag (e.g. ?OpenChat=true). 3. If the flag is present, call the Web Chat API’s window.voiceflow.chat.open() method to pop the widget open.
<script type="text/javascript">
(function (d, t) {
const v = d.createElement(t);
const s = d.getElementsByTagName(t)[0];

v.onload = function () {
// 1️⃣ initialise your widget
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production'
});

// 2️⃣ look for ?OpenChat=true
const params = new URLSearchParams(window.location.search);
const shouldOpen = params.get('OpenChat');

// 3️⃣ open only when the flag is present
if (shouldOpen === 'true') {
window.voiceflow.chat.open();
}
};

v.src = 'https://cdn.voiceflow.com/widget/bundle.mjs';
v.type = 'text/javascript';
s.parentNode.insertBefore(v, s);
})(document, 'script');
</script>
<script type="text/javascript">
(function (d, t) {
const v = d.createElement(t);
const s = d.getElementsByTagName(t)[0];

v.onload = function () {
// 1️⃣ initialise your widget
window.voiceflow.chat.load({
verify: { projectID: 'YOUR_PROJECT_ID' },
url: 'https://general-runtime.voiceflow.com',
versionID: 'production'
});

// 2️⃣ look for ?OpenChat=true
const params = new URLSearchParams(window.location.search);
const shouldOpen = params.get('OpenChat');

// 3️⃣ open only when the flag is present
if (shouldOpen === 'true') {
window.voiceflow.chat.open();
}
};

v.src = 'https://cdn.voiceflow.com/widget/bundle.mjs';
v.type = 'text/javascript';
s.parentNode.insertBefore(v, s);
})(document, 'script');
</script>
• Scan the QR code to a URL like https://your-site.com/?OpenChat=true, and the widget auto-opens.
• Visiting the page without that parameter leaves the launcher closed as usual.
• You can adapt the flag name/value to whatever you like. Reference: “Custom triggers” – Voiceflow Web Chat API docs (window.voiceflow.chat.open/close/show/hide). https://docs.voiceflow.com/docs/custom-triggers

Did you find this page helpful?