Skip to content

Instantly share code, notes, and snippets.

@lveillard
Created November 8, 2023 17:48
Show Gist options
  • Save lveillard/73d60b443380ac619d48e2345fb5bedb to your computer and use it in GitHub Desktop.
Save lveillard/73d60b443380ac619d48e2345fb5bedb to your computer and use it in GitHub Desktop.
Chatwoot
const ChatwootWidget: React.FC<ChatwootWidgetProps> = () => {
useEffect(() => {
// Define a function to load the Chatwoot script
const loadChatwootScript = () => {
const BASE_URL = {TOUR CHATWOOT SELF HOSTED URL);
const WEBSITE_TOKEN = {YOUR WEBSITE TOKEN}
const script = document.createElement('script');
script.src = `${BASE_URL}/packs/js/sdk.js`;
script.async = true;
script.onload = () => {
(window as any).chatwootSDK.run({
websiteToken: WEBSITE_TOKEN,
baseUrl: BASE_URL,
});
};
document.body.appendChild(script);
};
// Add Chatwoot Settings
(window as any).chatwootSettings = {
hideMessageBubble: false,
position: 'right',
locale: 'en',
type: 'standard',
};
loadChatwootScript();
}, []);
return null;
};
export default ChatwootWidget;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment