@filigran/chatbot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +14 -0
- package/.prettierignore +3 -0
- package/.prettierrc +8 -0
- package/README.md +215 -0
- package/base.json +21 -0
- package/dist/web.js +1 -0
- package/dist/web.umd.js +1 -0
- package/package.json +66 -0
- package/public/index.html +35 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:solid/typescript'],
|
|
4
|
+
plugins: ['@typescript-eslint', 'solid'],
|
|
5
|
+
parser: '@typescript-eslint/parser',
|
|
6
|
+
ignorePatterns: ['**/*.md'],
|
|
7
|
+
rules: {
|
|
8
|
+
'@next/next/no-img-element': 'off',
|
|
9
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
10
|
+
'solid/no-innerhtml': 'off',
|
|
11
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
12
|
+
'@typescript-eslint/no-explicit-any': 'off'
|
|
13
|
+
}
|
|
14
|
+
}
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD030 -->
|
|
2
|
+
|
|
3
|
+
# Filigran Chatbot
|
|
4
|
+
|
|
5
|
+
> 🪧 Most of the code from this repository is taken from [FlowiseEmbedChat](https://github.com/FlowiseAI/FlowiseChatEmbed).
|
|
6
|
+
>
|
|
7
|
+
> The chatbot interface and logic is kept, but we remove ties to flowise in favor of an agnostic approach, to be able to connect custom agentic server.
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Install:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Dev:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A development server will be running on http://localhost:5678 automatically. Update `public/index.html` to connect to your server:
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<!-- public/index.html -->
|
|
27
|
+
<script type="module">
|
|
28
|
+
import Chatbot from 'https://localhost:5678/web.js'; // Switch between './web.js' or 'https://localhost:5678/web.js'
|
|
29
|
+
Chatbot.init({
|
|
30
|
+
agenticUrl: 'https://your-agentic-service-url/endpoint', // Add your endpoint
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Build:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
yarn build
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
You can also customize chatbot with different configuration
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script type="module">
|
|
47
|
+
import Chatbot from 'https://localhost:5678/web.js'; // Switch between './web.js' or 'https://localhost:5678/web.js'
|
|
48
|
+
Chatbot.init({
|
|
49
|
+
agenticUrl: 'https://your-agentic-service-url/endpoint', // Add your endpoint
|
|
50
|
+
chatflowConfig: {
|
|
51
|
+
some: "variable" // this will be send in request header
|
|
52
|
+
},
|
|
53
|
+
observersConfig: {
|
|
54
|
+
// (optional) Allows you to execute code in parent based upon signal observations within the chatbot.
|
|
55
|
+
// The userinput field submitted to bot ("" when reset by bot)
|
|
56
|
+
observeUserInput: (userInput) => {
|
|
57
|
+
console.log({ userInput });
|
|
58
|
+
},
|
|
59
|
+
// The bot message stack has changed
|
|
60
|
+
observeMessages: (messages) => {
|
|
61
|
+
console.log({ messages });
|
|
62
|
+
},
|
|
63
|
+
// The bot loading signal changed
|
|
64
|
+
observeLoading: (loading) => {
|
|
65
|
+
console.log({ loading });
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
theme: {
|
|
69
|
+
button: {
|
|
70
|
+
backgroundColor: '#3B81F6',
|
|
71
|
+
right: 20,
|
|
72
|
+
bottom: 20,
|
|
73
|
+
size: 48, // small | medium | large | number
|
|
74
|
+
dragAndDrop: true,
|
|
75
|
+
iconColor: 'white',
|
|
76
|
+
customIconSrc: 'https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg',
|
|
77
|
+
autoWindowOpen: {
|
|
78
|
+
autoOpen: true, //parameter to control automatic window opening
|
|
79
|
+
openDelay: 2, // Optional parameter for delay time in seconds
|
|
80
|
+
autoOpenOnMobile: false, //parameter to control automatic window opening in mobile
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
tooltip: {
|
|
84
|
+
showTooltip: true,
|
|
85
|
+
tooltipMessage: 'Hi There 👋!',
|
|
86
|
+
tooltipBackgroundColor: 'black',
|
|
87
|
+
tooltipTextColor: 'white',
|
|
88
|
+
tooltipFontSize: 16,
|
|
89
|
+
},
|
|
90
|
+
disclaimer: {
|
|
91
|
+
title: 'Disclaimer',
|
|
92
|
+
message: 'By using this chatbot, you agree to the <a target="_blank" href="https://your-url/terms">Terms & Condition</a>',
|
|
93
|
+
textColor: 'black',
|
|
94
|
+
buttonColor: '#3b82f6',
|
|
95
|
+
buttonText: 'Start Chatting',
|
|
96
|
+
buttonTextColor: 'white',
|
|
97
|
+
blurredBackgroundColor: 'rgba(0, 0, 0, 0.4)', //The color of the blurred background that overlays the chat interface
|
|
98
|
+
backgroundColor: 'white',
|
|
99
|
+
denyButtonText: 'Cancel',
|
|
100
|
+
denyButtonBgColor: '#ef4444',
|
|
101
|
+
},
|
|
102
|
+
form: {
|
|
103
|
+
backgroundColor: 'white',
|
|
104
|
+
textColor: 'black',
|
|
105
|
+
}
|
|
106
|
+
customCSS: ``, // Add custom CSS styles. Use !important to override default styles
|
|
107
|
+
chatWindow: {
|
|
108
|
+
showTitle: true,
|
|
109
|
+
showAgentMessages: true,
|
|
110
|
+
title: 'Chat Bot',
|
|
111
|
+
titleAvatarSrc: 'https://raw.githubusercontent.com/walkxcode/dashboard-icons/main/svg/google-messages.svg',
|
|
112
|
+
titleBackgroundColor: '#3B81F6',
|
|
113
|
+
titleTextColor: '#ffffff',
|
|
114
|
+
welcomeMessage: 'Hello! This is custom welcome message',
|
|
115
|
+
errorMessage: 'This is a custom error message',
|
|
116
|
+
backgroundColor: '#ffffff',
|
|
117
|
+
backgroundImage: 'enter image path or link', // If set, this will overlap the background color of the chat window.
|
|
118
|
+
height: 700,
|
|
119
|
+
width: 400,
|
|
120
|
+
fontSize: 16,
|
|
121
|
+
starterPrompts: ['What is a bot?', 'Who are you?'], // It overrides the starter prompts set by the chat flow passed
|
|
122
|
+
starterPromptFontSize: 15,
|
|
123
|
+
clearChatOnReload: false, // If set to true, the chat will be cleared when the page reloads
|
|
124
|
+
sourceDocsTitle: 'Sources:',
|
|
125
|
+
renderHTML: true,
|
|
126
|
+
botMessage: {
|
|
127
|
+
backgroundColor: '#f7f8ff',
|
|
128
|
+
textColor: '#303235',
|
|
129
|
+
showAvatar: true,
|
|
130
|
+
avatarSrc: 'https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/parroticon.png',
|
|
131
|
+
},
|
|
132
|
+
userMessage: {
|
|
133
|
+
backgroundColor: '#3B81F6',
|
|
134
|
+
textColor: '#ffffff',
|
|
135
|
+
showAvatar: true,
|
|
136
|
+
avatarSrc: 'https://raw.githubusercontent.com/zahidkhawaja/langchain-chat-nextjs/main/public/usericon.png',
|
|
137
|
+
},
|
|
138
|
+
textInput: {
|
|
139
|
+
placeholder: 'Type your question',
|
|
140
|
+
backgroundColor: '#ffffff',
|
|
141
|
+
textColor: '#303235',
|
|
142
|
+
sendButtonColor: '#3B81F6',
|
|
143
|
+
maxChars: 50,
|
|
144
|
+
maxCharsWarningMessage: 'You exceeded the characters limit. Please input less than 50 characters.',
|
|
145
|
+
autoFocus: true, // If not used, autofocus is disabled on mobile and enabled on desktop. true enables it on both, false disables it on both.
|
|
146
|
+
sendMessageSound: true,
|
|
147
|
+
// sendSoundLocation: "send_message.mp3", // If this is not used, the default sound effect will be played if sendSoundMessage is true.
|
|
148
|
+
receiveMessageSound: true,
|
|
149
|
+
// receiveSoundLocation: "receive_message.mp3", // If this is not used, the default sound effect will be played if receiveSoundMessage is true.
|
|
150
|
+
},
|
|
151
|
+
feedback: {
|
|
152
|
+
color: '#303235',
|
|
153
|
+
},
|
|
154
|
+
dateTimeToggle: {
|
|
155
|
+
date: true,
|
|
156
|
+
time: true,
|
|
157
|
+
},
|
|
158
|
+
footer: {
|
|
159
|
+
textColor: '#303235',
|
|
160
|
+
text: 'Powered by',
|
|
161
|
+
company: 'Filigran',
|
|
162
|
+
companyLink: 'https://filigran.io',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
</script>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Development Mode (For Local Testing)
|
|
171
|
+
|
|
172
|
+
1. Configure your environment variables (see above)
|
|
173
|
+
|
|
174
|
+
2. Start the proxy server:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
yarn start
|
|
178
|
+
# Server will be available at:
|
|
179
|
+
# - Local: http://localhost:3001
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
3. Update the test page configuration:
|
|
183
|
+
|
|
184
|
+
- Open `public/index.html` in your code editor
|
|
185
|
+
- Modify the `agenticUrl`:
|
|
186
|
+
|
|
187
|
+
```html
|
|
188
|
+
<!-- public/index.html -->
|
|
189
|
+
<script type="module">
|
|
190
|
+
import Chatbot from './web.js';
|
|
191
|
+
Chatbot.init({
|
|
192
|
+
agenticUrl: 'https://your-agentic-service-url/endpoint', // Add your endpoint
|
|
193
|
+
});
|
|
194
|
+
</script>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
4. Open a new terminal and start the development server:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
yarn dev
|
|
201
|
+
# This will serve the test page on http://localhost:5678 automatically
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
5. Test the chatbot:
|
|
205
|
+
|
|
206
|
+
- Navigate to http://localhost:5678
|
|
207
|
+
- The chatbot should now be visible and functional
|
|
208
|
+
|
|
209
|
+
**Note:** The development URL (http://localhost:5678) is automatically added to allowed domains in development mode. You don't need to add it manually.
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
This project is a fork of [FlowiseEmbedChat](https://github.com/FlowiseAI/FlowiseChatEmbed), originally licensed under the [MIT License](https://github.com/FlowiseAI/Flowise/blob/master/LICENSE.md).
|
|
214
|
+
Original code remains under the MIT License.
|
|
215
|
+
Modifications and additional code are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
|
package/base.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Default",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": false,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"inlineSources": false,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"noUnusedLocals": false,
|
|
14
|
+
"noUnusedParameters": false,
|
|
15
|
+
"preserveWatchOutput": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"strict": true,
|
|
18
|
+
"downlevelIteration": true
|
|
19
|
+
},
|
|
20
|
+
"exclude": ["node_modules"]
|
|
21
|
+
}
|