@ibti-tech/chatbot 0.1.3 → 0.5.6

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/README.md CHANGED
@@ -1,36 +1,304 @@
1
- # IBTI Chatbot
1
+ # @ibti-tech/chatbot
2
2
 
3
- IBTI Chatbot is an assistent designed to provide intelligent responses and assist users effectively according to ibti available data from website and blog.
3
+ A modern and customizable React chatbot component developed by IBTI Soluções em TI. This package provides an intelligent conversational interface that can be easily integrated into any React application.
4
4
 
5
- ## How to use on your project
5
+ ## 📋 Features
6
6
 
7
- 1. Install using yarn or npm
7
+ - 🎨 **Customizable themes**: Support for light and dark themes
8
+ - 🌍 **Internationalization**: Support for Brazilian Portuguese (pt-BR) and English (en)
9
+ - 💬 **Modern interface**: Responsive and intuitive design
10
+ - ⚡ **Optimized performance**: Built with ESBuild for maximum performance
11
+ - 🔌 **Easy integration**: Simple React component to use
12
+ - 📱 **Responsive**: Works perfectly on desktop and mobile
8
13
 
9
- ```sh
10
- yarn add @ibti-tech/chatbot | npm install @ibti-tech/chatbot
14
+ ## 📦 Installation
15
+
16
+ Install the package using yarn or npm:
17
+
18
+ ```bash
19
+ # Using yarn
20
+ yarn add @ibti-tech/chatbot
21
+
22
+ # Using npm
23
+ npm install @ibti-tech/chatbot
11
24
  ```
12
25
 
13
- 2. Import Chatbot component into your react application and use it as a component
26
+ ## 🚀 Basic Usage
27
+
28
+ ### Import
14
29
 
15
30
  ```jsx
16
- import { Chatbot } from '@ibti-tech/chatbot'
31
+ import { ChatbotProvider, ChatbotBar } from '@ibti-tech/chatbot'
17
32
  ```
18
33
 
19
- 3. Use the component
34
+ ### Minimal Example
20
35
 
21
36
  ```jsx
22
- // {...}
23
- const MyFunctionalComponent = () => {
37
+ import React from 'react'
38
+ import { ChatbotProvider, ChatbotBar } from '@ibti-tech/chatbot'
39
+
40
+ function App() {
24
41
  return (
25
- <div>
42
+ <ChatbotProvider
43
+ locale="pt-BR"
44
+ apiURL="https://api.example.com"
45
+ theme="dark"
46
+ >
47
+ <ChatbotBar />
48
+ </ChatbotProvider>
49
+ )
50
+ }
51
+
52
+ export default App
53
+ ```
54
+
55
+ ## 📚 Available Components
56
+
57
+ ### `ChatbotProvider`
58
+
59
+ Context component that provides chatbot configuration and state to child components.
60
+
61
+ #### Props
62
+
63
+ | Prop | Type | Required | Description |
64
+ |------|------|----------|-------------|
65
+ | `locale` | `'pt-BR' \| 'en'` | ✅ | Chatbot interface language |
66
+ | `apiURL` | `string` | ✅ | Chatbot backend API URL |
67
+ | `theme` | `'light' \| 'dark'` | ✅ | Chatbot visual theme |
68
+ | `isOpen` | `boolean` | ❌ | Controls if the chatbot is initially open. Default: `false` |
69
+ | `texts` | `ChatbotTypes.Texts` | ❌ | Custom texts to override default translations. See [Custom Texts](#custom-texts) section |
70
+ | `children` | `ReactNode` | ❌ | Child components to be rendered |
71
+
72
+ ### `ChatbotBar`
73
+
74
+ Main component that displays the chatbot bar with toggle button and conversation interface.
75
+
76
+ #### Props
77
+
78
+ | Prop | Type | Required | Description |
79
+ |------|------|----------|-------------|
80
+ | `verticalPosition` | `'top' \| 'bottom'` | ❌ | Vertical position of the chatbot. Default: `'bottom'` |
81
+ | `horizontalPosition` | `'left' \| 'right'` | ❌ | Horizontal position of the chatbot. Default: `'right'` |
82
+
83
+ ### `ChatbotDevice`
84
+
85
+ Alternative component that can be used to display the chatbot on different devices or layouts.
86
+
87
+ #### Props
88
+
89
+ | Prop | Type | Required | Description |
90
+ |------|------|----------|-------------|
91
+ | `verticalPosition` | `'top' \| 'bottom'` | ❌ | Vertical position of the chatbot. Default: `'bottom'` |
92
+
93
+ ## 🎨 Themes
94
+
95
+ The chatbot supports two themes:
96
+
97
+ - **`light`**: Light theme with bright colors
98
+ - **`dark`**: Dark theme with dark colors
99
+
100
+ ```jsx
101
+ <ChatbotProvider theme="dark" ...>
102
+ <ChatbotBar />
103
+ </ChatbotProvider>
104
+ ```
105
+
106
+ ## 🌍 Localization
107
+
108
+ The chatbot supports the following languages:
109
+
110
+ - **`pt-BR`**: Brazilian Portuguese
111
+ - **`en`**: English
112
+
113
+ ```jsx
114
+ <ChatbotProvider locale="pt-BR" ...>
115
+ <ChatbotBar />
116
+ </ChatbotProvider>
117
+ ```
118
+
119
+ ### Custom Texts
120
+
121
+ You can customize all texts in the chatbot interface by passing a `texts` prop to `ChatbotProvider`. This allows you to override default translations for any locale.
122
+
123
+ ```jsx
124
+ <ChatbotProvider
125
+ locale="pt-BR"
126
+ apiURL="https://api.example.com"
127
+ theme="dark"
128
+ texts={{
129
+ 'pt-BR': {
130
+ CHATBOT_NAME: 'Meu Assistente',
131
+ INPUT_PLACEHOLDER: 'Digite sua mensagem...',
132
+ CHATBOT_BAR: {
133
+ OPEN: 'Abrir chat',
134
+ CLOSE: 'Fechar chat',
135
+ },
136
+ CHAT_FEEDBACK: {
137
+ TITLE: 'Avalie esta resposta',
138
+ DESCRIPTION: 'Sua opinião nos ajuda a melhorar',
139
+ MESSAGE_FIELD: 'Mensagem (opcional)',
140
+ SUBMIT_BUTTON: 'Enviar',
141
+ CLOSE_BUTTON: 'Fechar',
142
+ RATE: 'Avaliar',
143
+ },
144
+ SUGGESTED_QUESTIONS: {
145
+ TITLE: 'Perguntas sugeridas',
146
+ LOADING: 'Carregando...',
147
+ },
148
+ STATUS: {
149
+ ONLINE: 'Online',
150
+ LOADING: 'Carregando',
151
+ WRITING: 'Digitando...',
152
+ UNAVAILABLE: 'Indisponível',
153
+ INACTIVE: 'Inativo',
154
+ },
155
+ ERRORS: {
156
+ UNKNOWN: 'Erro desconhecido',
157
+ },
158
+ MESSAGE_ACTIONS: {
159
+ COPY: 'Copiar',
160
+ SHARE: 'Compartilhar',
161
+ RESEND: 'Reenviar',
162
+ },
163
+ USER_LABEL: 'Você',
164
+ WRITING_MESSAGE: 'Digitando...',
165
+ },
166
+ 'en': {
167
+ CHATBOT_NAME: 'My Assistant',
168
+ // ... other custom texts
169
+ },
170
+ }}
171
+ >
172
+ <ChatbotBar />
173
+ </ChatbotProvider>
174
+ ```
175
+
176
+ **Available text keys:**
177
+ - `CHATBOT_NAME`: Name displayed in the chatbot header
178
+ - `INPUT_PLACEHOLDER`: Placeholder text for the input field
179
+ - `CHATBOT_BAR.OPEN`: Text for opening the chatbot
180
+ - `CHATBOT_BAR.CLOSE`: Text for closing the chatbot
181
+ - `CHAT_FEEDBACK.*`: All feedback form texts
182
+ - `SUGGESTED_QUESTIONS.*`: Suggested questions section texts
183
+ - `STATUS.*`: Status indicator texts
184
+ - `ERRORS.*`: Error message texts
185
+ - `MESSAGE_ACTIONS.*`: Message action button texts
186
+ - `USER_LABEL`: Label for user messages
187
+ - `WRITING_MESSAGE`: Text shown when the bot is typing
188
+
189
+ ## 📝 Complete Example
190
+
191
+ ```jsx
192
+ import React from 'react'
193
+ import { ChatbotProvider, ChatbotBar } from '@ibti-tech/chatbot'
194
+
195
+ function MyApp() {
196
+ return (
197
+ <div className="app">
198
+ <h1>My Application</h1>
199
+
200
+ {/* Other components of your application */}
201
+
26
202
  <ChatbotProvider
27
203
  locale="pt-BR"
28
- apiURL="http://localhost:6061"
204
+ apiURL={process.env.REACT_APP_CHATBOT_API_URL || "http://localhost:6061"}
29
205
  theme="dark"
206
+ isOpen={false}
30
207
  >
31
- <ChatbotBar />
208
+ <ChatbotBar
209
+ verticalPosition="bottom"
210
+ horizontalPosition="right"
211
+ />
32
212
  </ChatbotProvider>
33
213
  </div>
34
214
  )
35
215
  }
216
+
217
+ export default MyApp
218
+ ```
219
+
220
+ ## 🎛️ Advanced Configuration
221
+
222
+ ### Positioning the Chatbot
223
+
224
+ You can control the position of the chatbot using the `ChatbotBar` component props:
225
+
226
+ ```jsx
227
+ // Bottom right (default)
228
+ <ChatbotBar />
229
+
230
+ // Top right
231
+ <ChatbotBar verticalPosition="top" />
232
+
233
+ // Bottom left
234
+ <ChatbotBar horizontalPosition="left" />
235
+
236
+ // Top left
237
+ <ChatbotBar
238
+ verticalPosition="top"
239
+ horizontalPosition="left"
240
+ />
241
+ ```
242
+
243
+ ### Controlling Initial State
244
+
245
+ Use the `isOpen` prop to control whether the chatbot starts open or closed:
246
+
247
+ ```jsx
248
+ <ChatbotProvider
249
+ locale="pt-BR"
250
+ apiURL="https://api.example.com"
251
+ theme="dark"
252
+ isOpen={true} // Chatbot starts open
253
+ >
254
+ <ChatbotBar />
255
+ </ChatbotProvider>
36
256
  ```
257
+
258
+ ## 🔧 Requirements
259
+
260
+ ### Peer Dependencies
261
+
262
+ This package requires the following dependencies that must be installed in your project:
263
+
264
+ - `react`: `^18.2.0`
265
+ - `react-dom`: `^18.2.0`
266
+ - `lodash`: `^4.17.21`
267
+ - `nookies`: `^2.5.2`
268
+
269
+ Make sure these dependencies are installed:
270
+
271
+ ```bash
272
+ yarn add react react-dom lodash nookies
273
+ # or
274
+ npm install react react-dom lodash nookies
275
+ ```
276
+
277
+ ## 📡 Backend API
278
+
279
+ The chatbot expects the backend API to be configured and accessible at the provided URL. The API must implement the necessary endpoints for:
280
+
281
+ - Sending messages
282
+ - Receiving responses
283
+ - Managing conversation history
284
+ - Suggested questions
285
+
286
+ ## 🐛 Issues and Support
287
+
288
+ If you encounter any issues or have questions:
289
+
290
+ 1. Check the [complete documentation](https://github.com/ibti-solutions/ibti-chatbot)
291
+ 2. Open an [issue on GitHub](https://github.com/ibti-solutions/ibti-chatbot/issues)
292
+ 3. Contact the IBTI team
293
+
294
+ ## 📄 License
295
+
296
+ ISC
297
+
298
+ ## 👥 Author
299
+
300
+ IBTI Soluções em TI
301
+
302
+ ---
303
+
304
+ For more information about development and contribution, see the [DEV_NOTES.md](./DEV_NOTES.md) file.