@jss-rule-engine/chat
Version:
64 lines (63 loc) • 1.97 kB
JavaScript
import React from 'react';
import ChatBot from "react-chatbotify";
import SitecoreChatPlugin from "../client/plugins/sitecoreChatPluginFactory";
export var ChatBotWidget = function (_a) {
var welcomeMessage = _a.welcomeMessage, startOptions = _a.startOptions, iconUrl = _a.iconUrl, flowId = _a.flowId, title = _a.title;
// example openai conversation
// you can replace with other LLMs such as Google Gemini
var flow = {
start: {
message: welcomeMessage,
options: {
items: startOptions,
reusable: true
},
chatDisabled: false,
start: true,
waitForAnswer: false,
transition: 0,
path: "loop"
},
loop: {
flowId: flowId
}
};
console.log('Chatbot flow: ', flow, flowId, startOptions);
var styles = {
// ...other styles
chatButtonStyle: {}
};
var chatBotSettings = {
general: {
embedded: false
},
fileAttachment: {
disabled: true
},
tooltip: {
mode: "NEVER",
title: "Talk to Sitecore chatbot"
},
header: {
showAvatar: false,
title: title,
},
chatWindow: {
showTypingIndicator: true
},
chatButton: {},
emoji: {
disabled: true
}
};
if (iconUrl) {
chatBotSettings.chatButton = {
icon: iconUrl
};
styles.chatButtonStyle = {
background: 'none'
};
}
return (React.createElement(ChatBot, { flow: flow, settings: chatBotSettings, styles: styles, id: 'chatbot-widget', key: "chatbot-widget-".concat(flowId), plugins: [SitecoreChatPlugin({ autoConfig: true, hostUrl: process.env.PUBLIC_URL })] }));
};
export default ChatBotWidget;