@unboundcx/sdk 4.13.25 → 4.13.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.25",
3
+ "version": "4.13.26",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -164,9 +164,84 @@ export class WebchatWidgetsService {
164
164
  }
165
165
  }
166
166
 
167
+ export class WebchatConversationMessagesService {
168
+ constructor(sdk) {
169
+ this.sdk = sdk;
170
+ }
171
+
172
+ /**
173
+ * List messages for a webchat conversation (agent view).
174
+ * @param {string} widgetId
175
+ * @param {string} engagementSessionId
176
+ * @param {Object} [options]
177
+ * @param {string} [options.before] - cursor: return messages created before this
178
+ * @param {number} [options.limit]
179
+ * @returns {Promise<Array<Object>>}
180
+ */
181
+ async list(widgetId, engagementSessionId, options = {}) {
182
+ this.sdk.validateParams(
183
+ { widgetId, engagementSessionId },
184
+ {
185
+ widgetId: { type: 'string', required: true },
186
+ engagementSessionId: { type: 'string', required: true },
187
+ },
188
+ );
189
+
190
+ const { before, limit } = options;
191
+
192
+ return internalRequest(
193
+ this.sdk,
194
+ `/webchat/widgets/${widgetId}/conversations/${engagementSessionId}/messages`,
195
+ 'GET',
196
+ { query: { before, limit } },
197
+ );
198
+ }
199
+
200
+ /**
201
+ * Send a message into a webchat conversation as an agent.
202
+ * @param {string} widgetId
203
+ * @param {string} engagementSessionId
204
+ * @param {Object} options
205
+ * @param {string} options.message
206
+ * @param {Object} [options.media]
207
+ * @returns {Promise<Object>}
208
+ */
209
+ async send(widgetId, engagementSessionId, options) {
210
+ this.sdk.validateParams(
211
+ {
212
+ widgetId,
213
+ engagementSessionId,
214
+ message: options?.message,
215
+ },
216
+ {
217
+ widgetId: { type: 'string', required: true },
218
+ engagementSessionId: { type: 'string', required: true },
219
+ message: { type: 'string', required: true },
220
+ },
221
+ );
222
+
223
+ const params = { body: { ...options } };
224
+
225
+ return internalRequest(
226
+ this.sdk,
227
+ `/webchat/widgets/${widgetId}/conversations/${engagementSessionId}/messages`,
228
+ 'POST',
229
+ params,
230
+ );
231
+ }
232
+ }
233
+
234
+ export class WebchatConversationsService {
235
+ constructor(sdk) {
236
+ this.sdk = sdk;
237
+ this.messages = new WebchatConversationMessagesService(sdk);
238
+ }
239
+ }
240
+
167
241
  export class WebchatService {
168
242
  constructor(sdk) {
169
243
  this.sdk = sdk;
170
244
  this.widgets = new WebchatWidgetsService(sdk);
245
+ this.conversations = new WebchatConversationsService(sdk);
171
246
  }
172
247
  }