@data-netmonk/mona-chat-widget 2.1.30 → 2.1.32

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
@@ -2,6 +2,146 @@
2
2
 
3
3
  Chat widget package developed by Netmonk data & solution team to be imported in Netmonk products
4
4
 
5
+ ## 🚅 Quick start
6
+
7
+ ### Prerequisites
8
+
9
+ ---
10
+
11
+ 1. Install dependencies
12
+ ```
13
+ npm install
14
+ ```
15
+ 2. Copy .env.example
16
+ ```
17
+ cp .env.example .env
18
+ ```
19
+ 3. Populate .env
20
+ 4. Enable mock mode (optional)
21
+
22
+ To test the chat widget without a backend server, set `VITE_USE_MOCK_RESPONSES=true` in your `.env` file. The widget will respond to messages like:
23
+ - "start", "hello", "hi", "halo" - Greeting messages
24
+ - "help", "bantuan" - Help information
25
+ - "terima kasih", "thank you" - Acknowledgments
26
+ - "bye", "goodbye" - Farewell messages
27
+ - And more! Check `src/components/ChatWidget/utils/helpers.js` for full list
28
+
29
+ ---
30
+
31
+ ### Mock Mode (Demo without Backend)
32
+
33
+ ---
34
+
35
+ The chat widget includes a built-in mock mode for testing and demonstrations without requiring a backend server.
36
+
37
+ **To enable mock mode:**
38
+ 1. Set `VITE_USE_MOCK_RESPONSES=true` in your `.env` file
39
+ 2. Run the app normally with `npm run dev`
40
+
41
+ **Mock responses include:**
42
+ - Greetings (hello, hi, halo, start) - with interactive buttons
43
+ - Help commands
44
+ - Device list with clickable buttons (type "devices" or "show devices")
45
+ - Thank you acknowledgments
46
+ - Farewells
47
+ - Time-based greetings (good morning, etc.)
48
+ - And automatically falls back to mock mode if backend fails
49
+
50
+ **Interactive Buttons Demo:**
51
+ Type these messages to see button responses:
52
+ - "start" - Welcome message with action buttons
53
+ - "show devices" or "devices" - List of devices as clickable buttons
54
+ - Click any button to trigger the next action
55
+
56
+ **To add custom mock responses:**
57
+ Edit the `mockBotResponses` object in `src/components/ChatWidget/utils/mockBotResponses.js`
58
+
59
+ For text-only responses:
60
+ ```javascript
61
+ "trigger": "Response text"
62
+ ```
63
+
64
+ For responses with buttons:
65
+ ```javascript
66
+ "trigger": {
67
+ text: "Your message here",
68
+ buttons: [
69
+ { title: "Button 1", payload: "action_1" },
70
+ { title: "Button 2", payload: "action_2" },
71
+ { title: "Link Button", url: "https://example.com" }
72
+ ]
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ ### Storybook
79
+
80
+ ---
81
+
82
+ 1. **How to run Storybook locally** (access at http://localhost:6006)
83
+
84
+ ```
85
+ npm run storybook
86
+ ```
87
+
88
+ 2. **How to build Storybook**
89
+
90
+ ```
91
+ npm run build-storybook
92
+ ```
93
+
94
+ 3. **How to serve Storybook**
95
+
96
+ ```
97
+ npm run serve-storybook
98
+ ```
99
+
100
+ ---
101
+
102
+ ### Library (how to update and publish)
103
+
104
+ ---
105
+
106
+ 1. **Commit changes**
107
+ ```
108
+ git add .
109
+ git commit -m "Your commit message"
110
+ ```
111
+ 2. **Update version**
112
+
113
+ ```bash
114
+ npm version patch # for bug fixes (1.0.0 -> 1.0.1)
115
+ ```
116
+
117
+ ```bash
118
+ npm version minor # for new features (1.0.0 -> 1.1.0)
119
+ ```
120
+
121
+ ```bash
122
+ npm version major # for breaking changes (1.0.0 -> 2.0.0)
123
+ ```
124
+
125
+ 3. **Build as a library** (build file at `/dist` directory)
126
+
127
+ ```
128
+ npm run build
129
+ ```
130
+
131
+ 4. **Copy declaration file to `/dist`**
132
+
133
+ ```
134
+ cp ./src/declarations/index.d.ts ./dist/index.d.ts
135
+ ```
136
+
137
+ 5. **Publish**
138
+
139
+ ```
140
+ npm publish
141
+ ```
142
+
143
+ ---
144
+
5
145
  ### Library (how to import on your project)
6
146
 
7
147
  ---