You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to add a chat widget to my Astrowind base Astro application.
I have tried both Crisp and Tawk - they both work with a Javascript to be added to the application.
I can see the logs in the browser console, however the widget pops up only on full page reload.
I have also tried to create a component containing the same script, and call it from within each page, or from within the main block of the PageLayout, but neither worked.
Any idea?
<scriptis:inlinedefine:vars={{tawkId: <myId>}}>
function ensureTawkWidget() {if(window.Tawk_API&&typeofwindow.Tawk_API.show==="function"){console.log("Tawk.to widget found! Making it visible...");window.Tawk_API.show();return;}
console.log("Tawk.to widget not found. Initializing...");
const script = document.createElement("script");
script.id = "tawk-script";
script.async = true;
script.src = `https://embed.tawk.to/${tawkId}`;
script.charset = "UTF-8";
script.setAttribute("crossorigin", "*");
script.onload = () =>{console.log("Tawk.to script loaded!");if(window.Tawk_API){window.Tawk_API.onLoad=function(){console.log("Tawk.to fully loaded, making widget visible...");window.Tawk_API.show();};}};document.head.appendChild(script);}document.addEventListener("astro:page-load",()=>{console.log("Astro Page Load Event Triggered");ensureTawkWidget();});
</script>
This discussion was converted from issue #592 on March 18, 2025 02:38.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to add a chat widget to my Astrowind base Astro application.
I have tried both Crisp and Tawk - they both work with a Javascript to be added to the application.
For Tawk, I have added the below script to
https://github.com/onwidget/astrowind/blob/main/src/components/common/BasicScripts.astro
I can see the logs in the browser console, however the widget pops up only on full page reload.
I have also tried to create a component containing the same script, and call it from within each page, or from within the main block of the PageLayout, but neither worked.
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions