wingbot 3.31.0 → 3.31.3

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": "wingbot",
3
- "version": "3.31.0",
3
+ "version": "3.31.3",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/BotApp.js CHANGED
@@ -23,6 +23,7 @@ const DEFAULT_API_URL = 'https://orchestrator-api.wingbot.ai';
23
23
 
24
24
  /** @typedef {import('./CallbackAuditLog')} AuditLog */
25
25
  /** @typedef {import('./BotAppSender').TlsOptions} TlsOptions */
26
+ /** @typedef {import('./ReturnSender').ReturnSenderOptions} ReturnSenderOptions */
26
27
 
27
28
  /**
28
29
  * @typedef {object} BotAppOptions
@@ -35,7 +36,7 @@ const DEFAULT_API_URL = 'https://orchestrator-api.wingbot.ai';
35
36
  * @prop {AuditLog} [auditLog]
36
37
  * @prop {TlsOptions} [tls]
37
38
  *
38
- * @typedef {ProcessorOptions & BotAppOptions} Options
39
+ * @typedef {ProcessorOptions & BotAppOptions & ReturnSenderOptions} Options
39
40
  */
40
41
 
41
42
  /**
@@ -66,9 +67,20 @@ class BotApp {
66
67
  preferSynchronousResponse = false,
67
68
  auditLog = null,
68
69
  tls = null,
70
+
71
+ textFilter,
72
+ logStandbyEvents,
73
+ confidentInputFilter,
74
+
69
75
  ...processorOptions
70
76
  } = options;
71
77
 
78
+ this._returnSenderOptions = {
79
+ textFilter,
80
+ logStandbyEvents,
81
+ confidentInputFilter
82
+ };
83
+
72
84
  this._secret = Promise.resolve(secret);
73
85
  this._fetch = fetch; // mock
74
86
  this._appId = appId;
@@ -200,7 +212,8 @@ class BotApp {
200
212
  const { mid = null } = message;
201
213
 
202
214
  if (sync || this._preferSynchronousResponse) {
203
- const sender = new ReturnSender({}, senderId, message, this._senderLogger);
215
+ const options = this._returnSenderOptions;
216
+ const sender = new ReturnSender(options, senderId, message, this._senderLogger);
204
217
  sender.propagatesWaitEvent = true;
205
218
  const res = await this._processor.processMessage(message, pageId, sender, { appId });
206
219
  await this._processSenderResponses(sender, senderId, pageId, headers);
@@ -226,6 +239,7 @@ class BotApp {
226
239
  }
227
240
 
228
241
  const options = {
242
+ ...this._returnSenderOptions,
229
243
  apiUrl: this._apiUrl,
230
244
  pageId,
231
245
  appId,
@@ -563,7 +563,11 @@ class BuildRouter extends Router {
563
563
 
564
564
  if ([
565
565
  'botbuild.include',
566
- 'botbuild.path'
566
+ 'botbuild.path',
567
+ 'botbuild.customCode',
568
+ 'botbuild.inlineCode',
569
+ 'botbuild.plugin',
570
+ 'botbuild.postback'
567
571
  ].includes(type)) {
568
572
  return fn;
569
573
  }
@@ -196,9 +196,22 @@ class ReturnSender {
196
196
  ? this.confidentInputFilter
197
197
  : this.textFilter;
198
198
 
199
+ let { message } = payload;
200
+
201
+ if (message && message.voice && message.voice.ssml) {
202
+ message = {
203
+ ...message,
204
+ text: message.text ? message.text : message.voice.ssml,
205
+ voice: {
206
+ ...message.voice,
207
+ ssml: filter(message.voice.ssml)
208
+ }
209
+ };
210
+ }
211
+
199
212
  // text message
200
- if (payload.message && payload.message.text) {
201
- let { text } = payload.message;
213
+ if (message && message.text) {
214
+ let { text } = message;
202
215
 
203
216
  if (req && req._anonymizedText) {
204
217
  text = req._anonymizedText;
@@ -207,27 +220,27 @@ class ReturnSender {
207
220
  return {
208
221
  ...payload,
209
222
  message: {
210
- ...payload.message,
223
+ ...message,
211
224
  text: filter(text)
212
225
  }
213
226
  };
214
227
  }
215
228
 
216
229
  // button message
217
- if (payload.message && payload.message.attachment
218
- && payload.message.attachment.type === 'template'
219
- && payload.message.attachment.payload
220
- && payload.message.attachment.payload.text) {
230
+ if (message && message.attachment
231
+ && message.attachment.type === 'template'
232
+ && message.attachment.payload
233
+ && message.attachment.payload.text) {
221
234
 
222
235
  return {
223
236
  ...payload,
224
237
  message: {
225
- ...payload.message,
238
+ ...message,
226
239
  attachment: {
227
- ...payload.message.attachment,
240
+ ...message.attachment,
228
241
  payload: {
229
- ...payload.message.attachment.payload,
230
- text: filter(payload.message.attachment.payload.text)
242
+ ...message.attachment.payload,
243
+ text: filter(message.attachment.payload.text)
231
244
  }
232
245
  }
233
246
  }