Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ You can also customize chatbot with different configuration
Chatbot.init({
chatflowid: '91e9c803-5169-4db9-8207-3c0915d71c5f',
apiHost: 'http://localhost:3000',
pageTitle: 'Flowise Chatbot Widget', // Optional: browser tab title. Empty string falls back to "Flowise Chatbot Widget"
chatflowConfig: {
// topK: 2
},
Expand Down
1 change: 1 addition & 0 deletions dist/components/Bot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export type observersConfigType = Record<'observeUserInput' | 'observeLoading' |
export type BotProps = {
chatflowid: string;
apiHost?: string;
pageTitle?: string;
onRequest?: (request: RequestInit) => Promise<void>;
chatflowConfig?: Record<string, unknown>;
backgroundColor?: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/Bot.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/web.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare const chatbot: {
initFull: (props: {
chatflowid: string;
apiHost?: string | undefined;
pageTitle?: string | undefined;
onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
chatflowConfig?: Record<string, unknown> | undefined;
observersConfig?: import("./components/Bot").observersConfigType | undefined;
Expand All @@ -12,6 +13,7 @@ declare const chatbot: {
init: (props: {
chatflowid: string;
apiHost?: string | undefined;
pageTitle?: string | undefined;
onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
chatflowConfig?: Record<string, unknown> | undefined;
observersConfig?: import("./components/Bot").observersConfigType | undefined;
Expand Down
2 changes: 1 addition & 1 deletion dist/web.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84,161 changes: 84,160 additions & 1 deletion dist/web.js

Large diffs are not rendered by default.

84,169 changes: 84,168 additions & 1 deletion dist/web.umd.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/window.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BubbleTheme } from './features/bubble/types';
type BotProps = {
chatflowid: string;
apiHost?: string;
pageTitle?: string;
onRequest?: (request: RequestInit) => Promise<void>;
chatflowConfig?: Record<string, unknown>;
observersConfig?: observersConfigType;
Expand Down
2 changes: 1 addition & 1 deletion dist/window.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/components/Bot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export type observersConfigType = Record<'observeUserInput' | 'observeLoading' |
export type BotProps = {
chatflowid: string;
apiHost?: string;
pageTitle?: string;
onRequest?: (request: RequestInit) => Promise<void>;
chatflowConfig?: Record<string, unknown>;
backgroundColor?: string;
Expand Down
9 changes: 9 additions & 0 deletions src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ import { BubbleTheme } from './features/bubble/types';
type BotProps = {
chatflowid: string;
apiHost?: string;
pageTitle?: string;
onRequest?: (request: RequestInit) => Promise<void>;
chatflowConfig?: Record<string, unknown>;
observersConfig?: observersConfigType;
theme?: BubbleTheme;
};

let elementUsed: Element | undefined;
const defaultPageTitle = 'Flowise Chatbot Widget';

const applyPageTitle = (pageTitle?: string) => {
if (typeof document === 'undefined' || pageTitle === undefined) return;
document.title = pageTitle.trim() || defaultPageTitle;
};

export const initFull = (props: BotProps & { id?: string }) => {
destroy();
applyPageTitle(props.pageTitle);
let fullElement = props.id ? document.getElementById(props.id) : document.querySelector('flowise-fullchatbot');
if (!fullElement) {
fullElement = document.createElement('flowise-fullchatbot');
Expand All @@ -28,6 +36,7 @@ export const initFull = (props: BotProps & { id?: string }) => {

export const init = (props: BotProps) => {
destroy();
applyPageTitle(props.pageTitle);
const element = document.createElement('flowise-chatbot');
Object.assign(element, props);
document.body.appendChild(element);
Expand Down