this code, it will load the webchat and send any m...
# 🌎general
f
this code, it will load the webchat and send any messages you have has a trigger:
Copy code
<script src="https://cdn.botpress.cloud/webchat/v0/inject.js"></script>
<script src="https://mediafiles.botpress.cloud/your-bot-id/webchat/config.js" defer></script>
<script>
      window.botpressWebChat.onEvent(
        function (ev) {
          window.botpressWebChat.sendEvent({
            type: "loadConversation",
          });
        },
        ["LIFECYCLE.LOADED"]
      );
      window.addEventListener("message", function (event) {
        // console.log(event.data.type);
        if (event.data.type == "LIFECYCLE.READY") {
          window.botpressWebChat.sendEvent({
            type: "trigger",
            channel: "web",
            payload: {
              text: "",
            },
          });
        }
      });
    </script>
2 Views