Skip to content

Instantly share code, notes, and snippets.

@Evavic44
Last active June 14, 2023 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Evavic44/80826db08e41bbf29691bb6d16763e9d to your computer and use it in GitHub Desktop.
Save Evavic44/80826db08e41bbf29691bb6d16763e9d to your computer and use it in GitHub Desktop.
Chatwoot live chat widget
import React from "react";

class ChatwootWidget extends React.Component {
componentDidMount() {
  window.chatwootSettings = {
    hideMessageBubble: false,
    position: "right",
    locale: "en",
    type: "standard", // [standard, expanded_bubble]
  };

  (function (d, t) {
    var BASE_URL = "https://app.chatwoot.com";
    var g = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    g.src = BASE_URL + "/packs/js/sdk.js";
    g.defer = true;
    g.async = true;
    s.parentNode.insertBefore(g, s);
    g.onload = function () {
      window.chatwootSDK.run({
        websiteToken: "ENTER TOKEN HERE",
        baseUrl: BASE_URL,
      });
    };
  })(document, "script");
}

render() {
    return null;
  }
}

export default ChatwootWidget;

Usage

import ChatwootWidget from "./source"

<ChatwootWidget />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment