@botonic/core 1.0.0-dev.0 → 2.23.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/CHANGELOG.md +226 -0
- package/README.md +7 -9
- package/package.json +19 -57
- package/src/index.d.ts +4 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/core-bot/index.d.ts +33 -0
- package/src/lib/core-bot/index.js +113 -0
- package/src/lib/core-bot/index.js.map +1 -0
- package/src/lib/hubtype-service/handoff.d.ts +4 -0
- package/src/lib/hubtype-service/handoff.js +32 -0
- package/src/lib/hubtype-service/handoff.js.map +1 -0
- package/src/lib/hubtype-service/index.d.ts +10 -0
- package/src/lib/hubtype-service/index.js +96 -0
- package/src/lib/hubtype-service/index.js.map +1 -0
- package/src/lib/messages/button.d.ts +8 -0
- package/src/lib/messages/button.js +10 -0
- package/src/lib/messages/button.js.map +1 -0
- package/src/lib/plugins/index.d.ts +2 -0
- package/src/lib/plugins/index.js +23 -0
- package/src/lib/plugins/index.js.map +1 -0
- package/src/lib/routes/index.d.ts +0 -0
- package/src/lib/routes/index.js +2 -0
- package/src/lib/routes/index.js.map +1 -0
- package/src/lib/routes/router.d.ts +14 -0
- package/src/lib/routes/router.js +68 -0
- package/src/lib/routes/router.js.map +1 -0
- package/src/lib/routes/types.d.ts +15 -0
- package/src/lib/routes/types.js +2 -0
- package/src/lib/routes/types.js.map +1 -0
- package/src/lib/utils/index.d.ts +7 -0
- package/{lib/esm/utils.js → src/lib/utils/index.js} +6 -34
- package/src/lib/utils/index.js.map +1 -0
- package/lib/cjs/constants.d.ts +0 -15
- package/lib/cjs/constants.js +0 -19
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/core-bot.d.ts +0 -33
- package/lib/cjs/core-bot.js +0 -85
- package/lib/cjs/core-bot.js.map +0 -1
- package/lib/cjs/debug/index.d.ts +0 -1
- package/lib/cjs/debug/index.js +0 -9
- package/lib/cjs/debug/index.js.map +0 -1
- package/lib/cjs/debug/inspector.d.ts +0 -24
- package/lib/cjs/debug/inspector.js +0 -72
- package/lib/cjs/debug/inspector.js.map +0 -1
- package/lib/cjs/errors.d.ts +0 -5
- package/lib/cjs/errors.js +0 -11
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/handoff.d.ts +0 -67
- package/lib/cjs/handoff.js +0 -183
- package/lib/cjs/handoff.js.map +0 -1
- package/lib/cjs/hubtype-service.d.ts +0 -69
- package/lib/cjs/hubtype-service.js +0 -190
- package/lib/cjs/hubtype-service.js.map +0 -1
- package/lib/cjs/i18n.d.ts +0 -2
- package/lib/cjs/i18n.js +0 -11
- package/lib/cjs/i18n.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -166
- package/lib/cjs/index.js +0 -58
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/models/events/connections/index.d.ts +0 -9
- package/lib/cjs/models/events/connections/index.js +0 -9
- package/lib/cjs/models/events/connections/index.js.map +0 -1
- package/lib/cjs/models/events/index.d.ts +0 -21
- package/lib/cjs/models/events/index.js +0 -11
- package/lib/cjs/models/events/index.js.map +0 -1
- package/lib/cjs/models/events/message/buttons.d.ts +0 -18
- package/lib/cjs/models/events/message/buttons.js +0 -3
- package/lib/cjs/models/events/message/buttons.js.map +0 -1
- package/lib/cjs/models/events/message/carousel.d.ts +0 -11
- package/lib/cjs/models/events/message/carousel.js +0 -3
- package/lib/cjs/models/events/message/carousel.js.map +0 -1
- package/lib/cjs/models/events/message/custom.d.ts +0 -6
- package/lib/cjs/models/events/message/custom.js +0 -3
- package/lib/cjs/models/events/message/custom.js.map +0 -1
- package/lib/cjs/models/events/message/index.d.ts +0 -30
- package/lib/cjs/models/events/message/index.js +0 -32
- package/lib/cjs/models/events/message/index.js.map +0 -1
- package/lib/cjs/models/events/message/location.d.ts +0 -6
- package/lib/cjs/models/events/message/location.js +0 -3
- package/lib/cjs/models/events/message/location.js.map +0 -1
- package/lib/cjs/models/events/message/media.d.ts +0 -18
- package/lib/cjs/models/events/message/media.js +0 -11
- package/lib/cjs/models/events/message/media.js.map +0 -1
- package/lib/cjs/models/events/message/postback.d.ts +0 -4
- package/lib/cjs/models/events/message/postback.js +0 -3
- package/lib/cjs/models/events/message/postback.js.map +0 -1
- package/lib/cjs/models/events/message/replies.d.ts +0 -7
- package/lib/cjs/models/events/message/replies.js +0 -3
- package/lib/cjs/models/events/message/replies.js.map +0 -1
- package/lib/cjs/models/events/message/text.d.ts +0 -8
- package/lib/cjs/models/events/message/text.js +0 -3
- package/lib/cjs/models/events/message/text.js.map +0 -1
- package/lib/cjs/models/user.d.ts +0 -10
- package/lib/cjs/models/user.js +0 -3
- package/lib/cjs/models/user.js.map +0 -1
- package/lib/cjs/output-parser/factory.d.ts +0 -4
- package/lib/cjs/output-parser/factory.js +0 -33
- package/lib/cjs/output-parser/factory.js.map +0 -1
- package/lib/cjs/output-parser/index.d.ts +0 -16
- package/lib/cjs/output-parser/index.js +0 -37
- package/lib/cjs/output-parser/index.js.map +0 -1
- package/lib/cjs/output-parser/parsers.d.ts +0 -28
- package/lib/cjs/output-parser/parsers.js +0 -138
- package/lib/cjs/output-parser/parsers.js.map +0 -1
- package/lib/cjs/output-parser/util.d.ts +0 -2
- package/lib/cjs/output-parser/util.js +0 -14
- package/lib/cjs/output-parser/util.js.map +0 -1
- package/lib/cjs/plugins.d.ts +0 -7
- package/lib/cjs/plugins.js +0 -45
- package/lib/cjs/plugins.js.map +0 -1
- package/lib/cjs/router.d.ts +0 -35
- package/lib/cjs/router.js +0 -262
- package/lib/cjs/router.js.map +0 -1
- package/lib/cjs/utils.d.ts +0 -10
- package/lib/cjs/utils.js +0 -84
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/constants.d.ts +0 -15
- package/lib/esm/constants.js +0 -16
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/core-bot.d.ts +0 -33
- package/lib/esm/core-bot.js +0 -81
- package/lib/esm/core-bot.js.map +0 -1
- package/lib/esm/debug/index.d.ts +0 -1
- package/lib/esm/debug/index.js +0 -2
- package/lib/esm/debug/index.js.map +0 -1
- package/lib/esm/debug/inspector.d.ts +0 -24
- package/lib/esm/debug/inspector.js +0 -65
- package/lib/esm/debug/inspector.js.map +0 -1
- package/lib/esm/errors.d.ts +0 -5
- package/lib/esm/errors.js +0 -7
- package/lib/esm/errors.js.map +0 -1
- package/lib/esm/handoff.d.ts +0 -67
- package/lib/esm/handoff.js +0 -170
- package/lib/esm/handoff.js.map +0 -1
- package/lib/esm/hubtype-service.d.ts +0 -69
- package/lib/esm/hubtype-service.js +0 -185
- package/lib/esm/hubtype-service.js.map +0 -1
- package/lib/esm/i18n.d.ts +0 -2
- package/lib/esm/i18n.js +0 -7
- package/lib/esm/i18n.js.map +0 -1
- package/lib/esm/index.d.ts +0 -166
- package/lib/esm/index.js +0 -49
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/models/events/connections/index.d.ts +0 -9
- package/lib/esm/models/events/connections/index.js +0 -6
- package/lib/esm/models/events/connections/index.js.map +0 -1
- package/lib/esm/models/events/index.d.ts +0 -21
- package/lib/esm/models/events/index.js +0 -8
- package/lib/esm/models/events/index.js.map +0 -1
- package/lib/esm/models/events/message/buttons.d.ts +0 -18
- package/lib/esm/models/events/message/buttons.js +0 -2
- package/lib/esm/models/events/message/buttons.js.map +0 -1
- package/lib/esm/models/events/message/carousel.d.ts +0 -11
- package/lib/esm/models/events/message/carousel.js +0 -2
- package/lib/esm/models/events/message/carousel.js.map +0 -1
- package/lib/esm/models/events/message/custom.d.ts +0 -6
- package/lib/esm/models/events/message/custom.js +0 -2
- package/lib/esm/models/events/message/custom.js.map +0 -1
- package/lib/esm/models/events/message/index.d.ts +0 -30
- package/lib/esm/models/events/message/index.js +0 -29
- package/lib/esm/models/events/message/index.js.map +0 -1
- package/lib/esm/models/events/message/location.d.ts +0 -6
- package/lib/esm/models/events/message/location.js +0 -2
- package/lib/esm/models/events/message/location.js.map +0 -1
- package/lib/esm/models/events/message/media.d.ts +0 -18
- package/lib/esm/models/events/message/media.js +0 -8
- package/lib/esm/models/events/message/media.js.map +0 -1
- package/lib/esm/models/events/message/postback.d.ts +0 -4
- package/lib/esm/models/events/message/postback.js +0 -2
- package/lib/esm/models/events/message/postback.js.map +0 -1
- package/lib/esm/models/events/message/replies.d.ts +0 -7
- package/lib/esm/models/events/message/replies.js +0 -2
- package/lib/esm/models/events/message/replies.js.map +0 -1
- package/lib/esm/models/events/message/text.d.ts +0 -8
- package/lib/esm/models/events/message/text.js +0 -2
- package/lib/esm/models/events/message/text.js.map +0 -1
- package/lib/esm/models/user.d.ts +0 -10
- package/lib/esm/models/user.js +0 -2
- package/lib/esm/models/user.js.map +0 -1
- package/lib/esm/output-parser/factory.d.ts +0 -4
- package/lib/esm/output-parser/factory.js +0 -29
- package/lib/esm/output-parser/factory.js.map +0 -1
- package/lib/esm/output-parser/index.d.ts +0 -16
- package/lib/esm/output-parser/index.js +0 -33
- package/lib/esm/output-parser/index.js.map +0 -1
- package/lib/esm/output-parser/parsers.d.ts +0 -28
- package/lib/esm/output-parser/parsers.js +0 -123
- package/lib/esm/output-parser/parsers.js.map +0 -1
- package/lib/esm/output-parser/util.d.ts +0 -2
- package/lib/esm/output-parser/util.js +0 -9
- package/lib/esm/output-parser/util.js.map +0 -1
- package/lib/esm/plugins.d.ts +0 -7
- package/lib/esm/plugins.js +0 -40
- package/lib/esm/plugins.js.map +0 -1
- package/lib/esm/router.d.ts +0 -35
- package/lib/esm/router.js +0 -258
- package/lib/esm/router.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -10
- package/lib/esm/utils.js.map +0 -1
- package/src/constants.ts +0 -15
- package/src/core-bot.ts +0 -144
- package/src/debug/index.ts +0 -6
- package/src/debug/inspector.ts +0 -102
- package/src/errors.ts +0 -11
- package/src/handoff.ts +0 -268
- package/src/hubtype-service.ts +0 -266
- package/src/i18n.ts +0 -12
- package/src/index.ts +0 -233
- package/src/models/events/connections/index.ts +0 -11
- package/src/models/events/index.ts +0 -39
- package/src/models/events/message/buttons.ts +0 -23
- package/src/models/events/message/carousel.ts +0 -13
- package/src/models/events/message/custom.ts +0 -7
- package/src/models/events/message/index.ts +0 -37
- package/src/models/events/message/location.ts +0 -7
- package/src/models/events/message/media.ts +0 -28
- package/src/models/events/message/postback.ts +0 -5
- package/src/models/events/message/replies.ts +0 -8
- package/src/models/events/message/text.ts +0 -12
- package/src/models/user.ts +0 -10
- package/src/output-parser/factory.ts +0 -40
- package/src/output-parser/index.ts +0 -38
- package/src/output-parser/parsers.ts +0 -190
- package/src/output-parser/util.ts +0 -8
- package/src/plugins.ts +0 -49
- package/src/router.ts +0 -316
- package/src/utils.ts +0 -84
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
## 2.23.0 (2026-03-23)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 2.22.1 (2026-03-19)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
9
|
+
## 2.22.0 (2026-03-16)
|
|
10
|
+
|
|
11
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
12
|
+
|
|
13
|
+
## 2.21.0 (2026-03-16)
|
|
14
|
+
|
|
15
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
16
|
+
|
|
17
|
+
## 2.20.0 (2026-03-13)
|
|
18
|
+
|
|
19
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
20
|
+
|
|
21
|
+
## 2.19.0 (2026-03-12)
|
|
22
|
+
|
|
23
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
24
|
+
|
|
25
|
+
## 2.18.0 (2026-03-04)
|
|
26
|
+
|
|
27
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
28
|
+
|
|
29
|
+
## 2.17.0 (2026-03-02)
|
|
30
|
+
|
|
31
|
+
### 🚀 Features
|
|
32
|
+
|
|
33
|
+
- botonic working with v2 input format ([#660](https://github.com/metis-ai/hubtype-product/pull/660))
|
|
34
|
+
|
|
35
|
+
### ❤️ Thank You
|
|
36
|
+
|
|
37
|
+
- Marc Rabat @vanbasten17
|
|
38
|
+
|
|
39
|
+
## Unreleased
|
|
40
|
+
|
|
41
|
+
### ✨ Features
|
|
42
|
+
|
|
43
|
+
- **Input format (BLT-2159):** Single CoreBot (v2). Lambda handler normalizes legacy → v2 with `normalizeToV2Input(mergedInput)` then calls `app.bot.input()`. Adapter: `legacyInputToInput`, `isInputLegacy`, `normalizeToV2Input` in `input-adapter.ts`. Accessors (`getText`, `getPayload`, etc.) preserved for reading/writing input. Removed `BOTONIC_INPUT_MODE`, `CoreBotLegacy`, and `libs/botonic/core/src/lib/core-bot/legacy/`.
|
|
44
|
+
- **CoreBot simplification:** Removed `CoreBotBase` abstraction and `v2/` folder. Single `CoreBot` class in `core-bot.ts`; `request-input.ts` and `input-accessors.ts` live in `core-bot/`. Config type renamed to `CoreBotConfig`.
|
|
45
|
+
|
|
46
|
+
## 2.16.0 (2026-02-23)
|
|
47
|
+
|
|
48
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
49
|
+
|
|
50
|
+
## 2.15.0 (2026-02-13)
|
|
51
|
+
|
|
52
|
+
### 🚀 Features
|
|
53
|
+
|
|
54
|
+
- update types for whatsapp template ([#658](https://github.com/metis-ai/hubtype-product/pull/658))
|
|
55
|
+
|
|
56
|
+
### ❤️ Thank You
|
|
57
|
+
|
|
58
|
+
- Oriol Raventós @Iru89
|
|
59
|
+
|
|
60
|
+
## 2.14.0 (2026-02-05)
|
|
61
|
+
|
|
62
|
+
### 🩹 Fixes
|
|
63
|
+
|
|
64
|
+
- **botonic:** align tsconfig outDir with Nx outputPath to fix TS6305 errors ([#594](https://github.com/metis-ai/hubtype-product/pull/594))
|
|
65
|
+
|
|
66
|
+
### ❤️ Thank You
|
|
67
|
+
|
|
68
|
+
- Marc Rabat @vanbasten17
|
|
69
|
+
|
|
70
|
+
## 2.13.4 (2026-02-02)
|
|
71
|
+
|
|
72
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
73
|
+
|
|
74
|
+
## 2.13.3 (2026-01-30)
|
|
75
|
+
|
|
76
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
77
|
+
|
|
78
|
+
## 2.13.2 (2026-01-30)
|
|
79
|
+
|
|
80
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
81
|
+
|
|
82
|
+
## 2.13.1 (2026-01-30)
|
|
83
|
+
|
|
84
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
85
|
+
|
|
86
|
+
## 2.13.0 (2026-01-29)
|
|
87
|
+
|
|
88
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
89
|
+
|
|
90
|
+
## 2.12.0 (2026-01-28)
|
|
91
|
+
|
|
92
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
93
|
+
|
|
94
|
+
## 2.11.5 (2026-01-28)
|
|
95
|
+
|
|
96
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
97
|
+
|
|
98
|
+
## 2.11.4 (2026-01-28)
|
|
99
|
+
|
|
100
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
101
|
+
|
|
102
|
+
## 2.11.3 (2026-01-28)
|
|
103
|
+
|
|
104
|
+
### 🩹 Fixes
|
|
105
|
+
|
|
106
|
+
- update entrypoints to use .js and .d.ts extensions for module and types ([#552](https://github.com/metis-ai/hubtype-product/pull/552))
|
|
107
|
+
|
|
108
|
+
### ❤️ Thank You
|
|
109
|
+
|
|
110
|
+
- David Hidalgo @Davidhidalgo
|
|
111
|
+
|
|
112
|
+
## 2.11.2 (2026-01-21)
|
|
113
|
+
|
|
114
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
115
|
+
|
|
116
|
+
## 2.11.1 (2026-01-21)
|
|
117
|
+
|
|
118
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
119
|
+
|
|
120
|
+
## 2.11.0 (2026-01-21)
|
|
121
|
+
|
|
122
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
123
|
+
|
|
124
|
+
## 2.10.1 (2026-01-19)
|
|
125
|
+
|
|
126
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
127
|
+
|
|
128
|
+
## 2.10.0 (2026-01-18)
|
|
129
|
+
|
|
130
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
131
|
+
|
|
132
|
+
## 2.9.1 (2026-01-17)
|
|
133
|
+
|
|
134
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
135
|
+
|
|
136
|
+
## 2.9.0 (2026-01-17)
|
|
137
|
+
|
|
138
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
139
|
+
|
|
140
|
+
## 2.8.1 (2026-01-16)
|
|
141
|
+
|
|
142
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
143
|
+
|
|
144
|
+
## 2.8.0 (2026-01-16)
|
|
145
|
+
|
|
146
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
147
|
+
|
|
148
|
+
## 2.7.1 (2026-01-16)
|
|
149
|
+
|
|
150
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
151
|
+
|
|
152
|
+
## 2.7.0 (2026-01-15)
|
|
153
|
+
|
|
154
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
155
|
+
|
|
156
|
+
## 2.6.0 (2025-12-09)
|
|
157
|
+
|
|
158
|
+
### 🚀 Features
|
|
159
|
+
|
|
160
|
+
- plugin-flow-builder enable SmartIntents and add tests ([#469](https://github.com/metis-ai/hubtype-product/pull/469))
|
|
161
|
+
|
|
162
|
+
### ❤️ Thank You
|
|
163
|
+
|
|
164
|
+
- Oriol Raventós @Iru89
|
|
165
|
+
|
|
166
|
+
## 2.5.0 (2025-12-09)
|
|
167
|
+
|
|
168
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
169
|
+
|
|
170
|
+
## 2.4.1 (2025-12-08)
|
|
171
|
+
|
|
172
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
173
|
+
|
|
174
|
+
## 2.4.0 (2025-12-05)
|
|
175
|
+
|
|
176
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
177
|
+
|
|
178
|
+
## 2.3.3 (2025-12-04)
|
|
179
|
+
|
|
180
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
181
|
+
|
|
182
|
+
## 2.3.2 (2025-12-04)
|
|
183
|
+
|
|
184
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
185
|
+
|
|
186
|
+
## 2.3.1 (2025-12-04)
|
|
187
|
+
|
|
188
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
189
|
+
|
|
190
|
+
## 2.3.0 (2025-12-04)
|
|
191
|
+
|
|
192
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
193
|
+
|
|
194
|
+
## 2.2.1 (2025-12-04)
|
|
195
|
+
|
|
196
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
|
197
|
+
|
|
198
|
+
## 2.2.0 (2025-12-04)
|
|
199
|
+
|
|
200
|
+
### 🚀 Features
|
|
201
|
+
|
|
202
|
+
- add custom tool and bot action ([#452](https://github.com/metis-ai/hubtype-product/pull/452))
|
|
203
|
+
- add support for all whatsapp outputs in domain, factories and whatsapp flow content fields ([#434](https://github.com/metis-ai/hubtype-product/pull/434))
|
|
204
|
+
- fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
|
|
205
|
+
|
|
206
|
+
### ❤️ Thank You
|
|
207
|
+
|
|
208
|
+
- David Hidalgo @Davidhidalgo
|
|
209
|
+
- Marc Rabat @vanbasten17
|
|
210
|
+
- Oriol Raventós @Iru89
|
|
211
|
+
|
|
212
|
+
## 2.1.0 (2025-12-02)
|
|
213
|
+
|
|
214
|
+
### 🚀 Features
|
|
215
|
+
|
|
216
|
+
- add support for all whatsapp outputs in domain, factories and whatsapp flow content fields ([#434](https://github.com/metis-ai/hubtype-product/pull/434))
|
|
217
|
+
- fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
|
|
218
|
+
|
|
219
|
+
### ❤️ Thank You
|
|
220
|
+
|
|
221
|
+
- David Hidalgo @Davidhidalgo
|
|
222
|
+
- Marc Rabat @vanbasten17
|
|
223
|
+
|
|
224
|
+
## 2.0.1-alpha.0 (2025-11-27)
|
|
225
|
+
|
|
226
|
+
This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
|
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Building
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Supporting internationalization (i18n)
|
|
9
|
-
- Operating with plugins
|
|
10
|
-
- Managing human handoff
|
|
11
|
-
- Communicating with Hubtype's server
|
|
7
|
+
Run `nx build core` to build the library.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test core` to execute the unit tests via [Vitest](https://vitest.dev/).
|
package/package.json
CHANGED
|
@@ -1,64 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"lint": "npm run lint_ci -- --fix",
|
|
13
|
-
"lint_ci": "../../node_modules/.bin/eslint_d --cache --quiet '*.js' 'src/**/*.ts*'",
|
|
14
|
-
"build": "rm -rf lib && ../../node_modules/.bin/tsc -p tsconfig.json && ../../node_modules/.bin/tsc -p tsconfig.esm.json",
|
|
15
|
-
"build:watch": "../../node_modules/.bin/tsc --watch",
|
|
16
|
-
"cloc": "../../scripts/qa/cloc-package.sh ."
|
|
3
|
+
"version": "2.23.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"module": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"import": "./src/index.js"
|
|
11
|
+
}
|
|
17
12
|
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/hubtype/botonic.git"
|
|
21
|
-
},
|
|
22
|
-
"author": "",
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://github.com/hubtype/botonic/issues"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"src/**",
|
|
28
|
-
"lib/**",
|
|
29
|
-
"index.d.ts",
|
|
30
|
-
"README.md"
|
|
31
|
-
],
|
|
32
13
|
"dependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"fast-xml-parser": "^3.19.0",
|
|
36
|
-
"html-entities": "^2.3.2",
|
|
37
|
-
"pusher-js": "^5.1.1"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@babel/cli": "^7.11.5",
|
|
41
|
-
"@babel/core": "^7.11.6",
|
|
42
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
|
|
43
|
-
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
44
|
-
"@babel/plugin-transform-runtime": "^7.9.6",
|
|
45
|
-
"@babel/preset-env": "^7.9.6",
|
|
46
|
-
"babel-plugin-add-module-exports": "^1.0.2"
|
|
47
|
-
},
|
|
48
|
-
"homepage": "https://github.com/hubtype/botonic#readme",
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=10.0.0"
|
|
14
|
+
"@botonic/shared": "2.23.0",
|
|
15
|
+
"tslib": "^2.3.0"
|
|
51
16
|
},
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"conversational-ui",
|
|
57
|
-
"javascript"
|
|
17
|
+
"references": [
|
|
18
|
+
{
|
|
19
|
+
"path": "../shared/tsconfig.lib.json"
|
|
20
|
+
}
|
|
58
21
|
],
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"root": true
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
62
24
|
},
|
|
63
|
-
"
|
|
64
|
-
}
|
|
25
|
+
"main": "./src/index.js"
|
|
26
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BotContext, BotonicRequest, ResolvedPlugins } from '@botonic/shared';
|
|
2
|
+
import { HubtypeExternalAPIService } from '../hubtype-service';
|
|
3
|
+
import { Route } from '../routes/types';
|
|
4
|
+
/** Config for CoreBot. */
|
|
5
|
+
export interface CoreBotConfig {
|
|
6
|
+
appId?: string;
|
|
7
|
+
defaultDelay?: number;
|
|
8
|
+
defaultRoutes?: (botContext: BotContext) => Route[];
|
|
9
|
+
defaultTyping?: number;
|
|
10
|
+
plugins?: ResolvedPlugins;
|
|
11
|
+
routes: (botContext: BotContext) => Route[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CoreBot: accepts RequestInput; normalizes to Input (v2) inside input().
|
|
15
|
+
* Runs pipeline: input() → getBotContext → runInput (route, plugins, redirect).
|
|
16
|
+
*/
|
|
17
|
+
export declare class CoreBot {
|
|
18
|
+
appId?: string;
|
|
19
|
+
defaultDelay: number;
|
|
20
|
+
defaultRoutes: (botContext: BotContext) => Route[];
|
|
21
|
+
defaultTyping: number;
|
|
22
|
+
plugins: ResolvedPlugins;
|
|
23
|
+
routes: (botContext: BotContext) => Route[];
|
|
24
|
+
hubtypeService: HubtypeExternalAPIService;
|
|
25
|
+
private readonly botonicContextFactory;
|
|
26
|
+
constructor({ appId, defaultDelay, defaultRoutes, defaultTyping, plugins, routes, }: CoreBotConfig);
|
|
27
|
+
input(botRequest: BotonicRequest): Promise<void>;
|
|
28
|
+
private runInput;
|
|
29
|
+
private runPrePlugins;
|
|
30
|
+
private getRoute;
|
|
31
|
+
private runPostPlugins;
|
|
32
|
+
private runRedirectAction;
|
|
33
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { BotonicAction, BotonicContextFactory, MessageType, PluginMode, } from '@botonic/shared';
|
|
3
|
+
import { HubtypeExternalAPIService } from '../hubtype-service';
|
|
4
|
+
import { runPlugins } from '../plugins';
|
|
5
|
+
import { Router } from '../routes/router';
|
|
6
|
+
/**
|
|
7
|
+
* CoreBot: accepts RequestInput; normalizes to Input (v2) inside input().
|
|
8
|
+
* Runs pipeline: input() → getBotContext → runInput (route, plugins, redirect).
|
|
9
|
+
*/
|
|
10
|
+
export class CoreBot {
|
|
11
|
+
constructor({ appId, defaultDelay = 0.4, defaultRoutes = () => [], defaultTyping = 0.6, plugins, routes, }) {
|
|
12
|
+
this.hubtypeService = new HubtypeExternalAPIService();
|
|
13
|
+
this.appId = appId;
|
|
14
|
+
this.defaultDelay = defaultDelay;
|
|
15
|
+
this.defaultRoutes = defaultRoutes;
|
|
16
|
+
this.defaultTyping = defaultTyping;
|
|
17
|
+
this.plugins = plugins || {};
|
|
18
|
+
this.routes = routes;
|
|
19
|
+
this.botonicContextFactory = new BotonicContextFactory(this.hubtypeService, this.plugins, this.defaultTyping, this.defaultDelay);
|
|
20
|
+
}
|
|
21
|
+
input(botRequest) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const botContext = this.botonicContextFactory.create(botRequest);
|
|
24
|
+
yield this.runInput(botContext);
|
|
25
|
+
if (botContext.session.isBotonicActionRedirect()) {
|
|
26
|
+
yield this.runRedirectAction(botContext);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
runInput(botContext) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
var _a;
|
|
33
|
+
if (botContext.input.type === MessageType.TypingEvent) {
|
|
34
|
+
botContext.response = {
|
|
35
|
+
status: 200,
|
|
36
|
+
response: 'OK',
|
|
37
|
+
};
|
|
38
|
+
return botContext;
|
|
39
|
+
}
|
|
40
|
+
yield this.runPrePlugins(botContext);
|
|
41
|
+
const route = yield this.getRoute(botContext);
|
|
42
|
+
const actionResponse = yield ((_a = route.action) === null || _a === void 0 ? void 0 : _a.call(route, botContext));
|
|
43
|
+
yield this.runPostPlugins(botContext, actionResponse);
|
|
44
|
+
if (botContext.session.isFirstInteraction) {
|
|
45
|
+
yield botContext.updateBotSession({ isFirstInteraction: false });
|
|
46
|
+
}
|
|
47
|
+
botContext.response = actionResponse !== null && actionResponse !== void 0 ? actionResponse : { status: 200, response: 'OK' };
|
|
48
|
+
return botContext;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
runPrePlugins(botContext) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (this.plugins) {
|
|
54
|
+
yield runPlugins({
|
|
55
|
+
botContext,
|
|
56
|
+
mode: PluginMode.PRE,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
getRoute(botContext) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const computedRoutes = this.routes(botContext);
|
|
64
|
+
const router = new Router([
|
|
65
|
+
...computedRoutes,
|
|
66
|
+
...this.defaultRoutes(botContext),
|
|
67
|
+
]);
|
|
68
|
+
const route = router.processInput(botContext);
|
|
69
|
+
return route;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
runPostPlugins(botContext, response) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (this.plugins) {
|
|
75
|
+
yield runPlugins({
|
|
76
|
+
botContext,
|
|
77
|
+
mode: PluginMode.POST,
|
|
78
|
+
response,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
runRedirectAction(botContext_1) {
|
|
84
|
+
return __awaiter(this, arguments, void 0, function* (botContext, numOfRedirects = 0) {
|
|
85
|
+
var _a;
|
|
86
|
+
if (numOfRedirects > 10) {
|
|
87
|
+
throw new Error('Maximum BotAction recursive calls reached (10)');
|
|
88
|
+
}
|
|
89
|
+
const nextPayload = botContext.session.getBotonicActionPayload(BotonicAction.Redirect);
|
|
90
|
+
const hadPayload = Boolean(nextPayload);
|
|
91
|
+
if (!hadPayload) {
|
|
92
|
+
yield botContext.updateBotSession({ botonicAction: null });
|
|
93
|
+
botContext.response = {
|
|
94
|
+
status: 200,
|
|
95
|
+
response: 'OK',
|
|
96
|
+
};
|
|
97
|
+
return botContext;
|
|
98
|
+
}
|
|
99
|
+
yield botContext.updateBotSession({ botonicAction: null });
|
|
100
|
+
botContext.input.setAsPostback(nextPayload);
|
|
101
|
+
const followUpContext = yield this.runInput(botContext);
|
|
102
|
+
if (botContext.session.isBotonicActionRedirect()) {
|
|
103
|
+
return yield this.runRedirectAction(botContext, numOfRedirects + 1);
|
|
104
|
+
}
|
|
105
|
+
followUpContext.response = (_a = followUpContext.response) !== null && _a !== void 0 ? _a : {
|
|
106
|
+
status: 200,
|
|
107
|
+
response: 'OK',
|
|
108
|
+
};
|
|
109
|
+
return followUpContext;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/core-bot/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,aAAa,EACb,qBAAqB,EAErB,WAAW,EACX,UAAU,GAEX,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAazC;;;GAGG;AACH,MAAM,OAAO,OAAO;IAUlB,YAAY,EACV,KAAK,EACL,YAAY,GAAG,GAAG,EAClB,aAAa,GAAG,GAAG,EAAE,CAAC,EAAE,EACxB,aAAa,GAAG,GAAG,EACnB,OAAO,EACP,MAAM,GACQ;QACd,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAyB,EAAE,CAAA;QACrD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,qBAAqB,GAAG,IAAI,qBAAqB,CACpD,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,YAAY,CAClB,CAAA;IACH,CAAC;IAEK,KA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AAU,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAC1D,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,WAAY,CAAC,CAAA;YAE5C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;YAEvD,IAAI,UAAU,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;gBACjD,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAC,CAAA;YACrE,CAAC;YAED,eAAe,CAAC,QAAQ,GAAG,MAAA,eAAe,CAAC,QAAQ,mCAAI;gBACrD,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,IAAI;aACf,CAAA;YACD,OAAO,eAAe,CAAA;QACxB,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
// function contextDefaults(context: any): any {
|
|
3
|
+
// return {
|
|
4
|
+
// timeoutMs: context.timeoutMs || 10000,
|
|
5
|
+
// }
|
|
6
|
+
// }
|
|
7
|
+
export function storeCaseRating(session_1, rating_1) {
|
|
8
|
+
return __awaiter(this, arguments, void 0, function* (session, rating, context = {}) {
|
|
9
|
+
if (session.isTestIntegration) {
|
|
10
|
+
return Promise.resolve({ status: 'ok' });
|
|
11
|
+
}
|
|
12
|
+
const baseUrl = session.hubtypeApi ||
|
|
13
|
+
// @ts-expect-error - VITE_HUBTYPE_API_URL is not defined in the environment
|
|
14
|
+
import.meta.env['VITE_HUBTYPE_API_URL'];
|
|
15
|
+
const chatId = session.user.id;
|
|
16
|
+
// context = contextDefaults(context)
|
|
17
|
+
const response = yield fetch(`${baseUrl}/v1/chats/${chatId}/store_case_rating/`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${session.accessToken}`,
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({ chat_id: chatId, rating }),
|
|
24
|
+
// signal: AbortSignal.timeout((context as any).timeoutMs),
|
|
25
|
+
});
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
28
|
+
}
|
|
29
|
+
return yield response.json();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/hubtype-service/handoff.ts"],"names":[],"mappings":";AACA,gDAAgD;AAChD,aAAa;AACb,6CAA6C;AAC7C,MAAM;AACN,IAAI;AAEJ,MAAM,UAAgB,eAAe;yDACnC,OAA8B,EAC9B,MAAc,EACd,UAAe,EAAE;QAEjB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1C,CAAC;QACD,MAAM,OAAO,GACX,OAAO,CAAC,UAAU;YAClB,4EAA4E;YAC5E,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;QAC9B,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,OAAO,aAAa,MAAM,qBAAqB,EAClD;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE;gBAC9C,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YACjD,6DAA6D;SAC9D,CACF,CAAA;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BotContext, BotonicRequestSession, BotonicSessionUpdate, BotServerMessage, HandoffOptions, HubtypeServicePort, ResolvedPlugins, UserExtraData } from '@botonic/shared';
|
|
2
|
+
export declare class HubtypeExternalAPIService implements HubtypeServicePort {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
constructor(baseUrl?: string);
|
|
5
|
+
updateBotSession<TExtraData extends UserExtraData = UserExtraData>(botContext: BotContext<ResolvedPlugins, TExtraData>, updates: BotonicSessionUpdate<TExtraData>): Promise<void>;
|
|
6
|
+
getBotSession(botContext: BotContext): Promise<Omit<BotonicRequestSession, '_access_token'>>;
|
|
7
|
+
doHandoff(botContext: BotContext, handoffOptions?: HandoffOptions): Promise<any>;
|
|
8
|
+
sendMessage(botContext: BotContext, message: BotServerMessage): Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
export { storeCaseRating } from './handoff';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { BotonicContextSession, sessionUpdateToPatchBody, } from '@botonic/shared';
|
|
3
|
+
export class HubtypeExternalAPIService {
|
|
4
|
+
constructor(
|
|
5
|
+
// @ts-expect-error - VITE_HUBTYPE_API_URL is not defined in the environment
|
|
6
|
+
baseUrl = import.meta.env['VITE_HUBTYPE_API_URL'] // TODO: Should this come from vite or directly taken from lambda process.env?
|
|
7
|
+
) {
|
|
8
|
+
this.baseUrl = baseUrl;
|
|
9
|
+
}
|
|
10
|
+
updateBotSession(botContext, updates) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const patchedSession = sessionUpdateToPatchBody(updates);
|
|
13
|
+
const sessionToUpdate = Object.assign({}, patchedSession);
|
|
14
|
+
delete sessionToUpdate._access_token;
|
|
15
|
+
delete sessionToUpdate._hubtype_api;
|
|
16
|
+
// When patching user, send full user so backend replacement does not drop id, provider, contact_info, etc.
|
|
17
|
+
// TODO: Beware this kind of unstructuring so we keep all levels of the user object
|
|
18
|
+
if (sessionToUpdate.user != null &&
|
|
19
|
+
typeof sessionToUpdate.user === 'object') {
|
|
20
|
+
sessionToUpdate.user = Object.assign(Object.assign({}, botContext.session.raw.user), sessionToUpdate.user);
|
|
21
|
+
}
|
|
22
|
+
const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/context/`, {
|
|
23
|
+
method: 'PATCH',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify(sessionToUpdate),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
console.error('Response error', response);
|
|
31
|
+
throw new Error('Failed to update bot session');
|
|
32
|
+
}
|
|
33
|
+
const didUpdateBotonicAction = 'botonicAction' in updates;
|
|
34
|
+
const previousBotonicAction = didUpdateBotonicAction
|
|
35
|
+
? undefined
|
|
36
|
+
: botContext.session.raw._botonic_action;
|
|
37
|
+
const sessionUpdated = yield response.json();
|
|
38
|
+
sessionUpdated._access_token = botContext.session.accessToken;
|
|
39
|
+
if (previousBotonicAction !== undefined) {
|
|
40
|
+
sessionUpdated._botonic_action = previousBotonicAction;
|
|
41
|
+
}
|
|
42
|
+
botContext.session = new BotonicContextSession(sessionUpdated);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getBotSession(botContext) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/context/`);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new Error('Failed to get bot session');
|
|
50
|
+
}
|
|
51
|
+
const sessionResponse = yield response.json();
|
|
52
|
+
return sessionResponse;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
doHandoff(botContext, handoffOptions) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/do_handoff/`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: {
|
|
60
|
+
'Content-Type': 'application/json',
|
|
61
|
+
Authorization: `Bearer ${botContext.session.accessToken}`,
|
|
62
|
+
},
|
|
63
|
+
body: JSON.stringify(Object.assign(Object.assign({}, handoffOptions), { bot_interaction_id: botContext.input.botInteractionId })),
|
|
64
|
+
});
|
|
65
|
+
if (!response.ok) {
|
|
66
|
+
throw new Error('Failed to do handoff');
|
|
67
|
+
}
|
|
68
|
+
return yield response.json();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
sendMessage(botContext, message) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
var _a;
|
|
74
|
+
const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/send_message/`, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
Authorization: `Bearer ${botContext.session.accessToken}`,
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify(message),
|
|
81
|
+
});
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
const contentType = (_a = response.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
|
|
84
|
+
const isJson = contentType.includes('application/json');
|
|
85
|
+
const responseError = isJson
|
|
86
|
+
? yield response.json()
|
|
87
|
+
: yield response.text();
|
|
88
|
+
console.error('Response error', responseError);
|
|
89
|
+
throw new Error('Failed to post message');
|
|
90
|
+
}
|
|
91
|
+
return yield response.json();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export { storeCaseRating } from './handoff';
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/hubtype-service/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,qBAAqB,EAOrB,wBAAwB,GAEzB,MAAM,iBAAiB,CAAA;AAExB,MAAM,OAAO,yBAAyB;IAGpC;IACE,4EAA4E;IAC5E,UAAkB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,8EAA8E;;QAExI,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEK,gBAAgB,CACpB,UAAmD,EACnD,OAAyC;;YAEzC,MAAM,cAAc,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;YACxD,MAAM,eAAe,GAAG,kBAAK,cAAc,CAG1C,CAAA;YACD,OAAO,eAAe,CAAC,aAAa,CAAA;YACpC,OAAO,eAAe,CAAC,YAAY,CAAA;YACnC,2GAA2G;YAC3G,mFAAmF;YACnF,IACE,eAAe,CAAC,IAAI,IAAI,IAAI;gBAC5B,OAAO,eAAe,CAAC,IAAI,KAAK,QAAQ,EACxC,CAAC;gBACD,eAAe,CAAC,IAAI,mCACf,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAC3B,eAAe,CAAC,IAAI,CACxB,CAAA;YACH,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,IAAI,CAAC,OAAO,oCAAoC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,UAAU,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,EAC3H;gBACE,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EA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