Embed

You can embed the chat widget on your website. Simply copy the provided code and paste it anywhere within the tag of your HTML file.

The following video shows how to inject the widget script into any webpage.

You can pass chatflowConfig JSON object to override existing configuration. This is the same as Override Config in API.

<script type="module">
  import Chatbot from 'https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js';
  Chatbot.init({
    chatflowid: 'abc',
    apiHost: 'http://localhost:3000',
    chatflowConfig: {
      "sessionId": "123",
      "returnSourceDocuments": true
    }
  })
</script>

This allows you to execute code in parent based upon signal observations within the chatbot.

<script type="module">
  import Chatbot from 'https://cdn.jsdelivr.net/npm/flowise-embed/dist/web.js';
  Chatbot.init({
    chatflowid: 'abc',
    apiHost: 'http://localhost:3000',
    observersConfig: {
      // User input has changed
      observeUserInput: (userInput) => {
        console.log({ userInput });
      },
      // The bot message stack has changed
      observeMessages: (messages) => {
        console.log({ messages });
      },
      // The bot loading signal changed
      observeLoading: (loading) => {
        console.log({ loading });
      },
    },
  })
</script>
  • Then you can make any code changes

  • Run pnpm build to pick up the changes

  • Push changes to the forked repo

  • You can then use it as embedded chat like so:

Replace username to your Github username, and forked-repo to your forked repo.

An alternative to jsdelivr is unpkg. Here is an example:

When using embedded chat widget, there's chance that you might face CORS issue like:

Access to fetch at 'https://<your-flowise.com>/api/v1/prediction/' from origin 'https://<your-flowise.com>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

If using local Git clone, place the env variables inside Flowise/packages/server/.env

These two videos will teach you how to embed the Flowise widget into a website.