@botonic/plugin-flow-builder 0.45.0-alpha.1 → 0.46.0-alpha.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.
Files changed (84) hide show
  1. package/lib/cjs/action/ai-agent.js +2 -0
  2. package/lib/cjs/action/ai-agent.js.map +1 -1
  3. package/lib/cjs/action/first-interaction.js +1 -1
  4. package/lib/cjs/action/first-interaction.js.map +1 -1
  5. package/lib/cjs/action/index.js +1 -1
  6. package/lib/cjs/action/index.js.map +1 -1
  7. package/lib/cjs/action/knowledge-bases.js +1 -1
  8. package/lib/cjs/action/knowledge-bases.js.map +1 -1
  9. package/lib/cjs/content-fields/flow-ai-agent.d.ts +3 -1
  10. package/lib/cjs/content-fields/flow-ai-agent.js +5 -0
  11. package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
  12. package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +2 -1
  13. package/lib/cjs/content-fields/flow-whatsapp-template.js +13 -5
  14. package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
  15. package/lib/cjs/content-fields/hubtype-fields/ai-agent.d.ts +3 -0
  16. package/lib/cjs/content-fields/hubtype-fields/whatsapp-template.d.ts +11 -8
  17. package/lib/cjs/flow-factory.js +1 -1
  18. package/lib/cjs/flow-factory.js.map +1 -1
  19. package/lib/cjs/index.js +1 -1
  20. package/lib/cjs/index.js.map +1 -1
  21. package/lib/cjs/user-input/capture-user-input-api.d.ts +2 -1
  22. package/lib/cjs/user-input/capture-user-input-api.js +6 -5
  23. package/lib/cjs/user-input/capture-user-input-api.js.map +1 -1
  24. package/lib/cjs/user-input/index.js +6 -4
  25. package/lib/cjs/user-input/index.js.map +1 -1
  26. package/lib/cjs/user-input/keyword.d.ts +4 -2
  27. package/lib/cjs/user-input/keyword.js +5 -4
  28. package/lib/cjs/user-input/keyword.js.map +1 -1
  29. package/lib/cjs/user-input/smart-intent.d.ts +2 -2
  30. package/lib/cjs/user-input/smart-intent.js +5 -5
  31. package/lib/cjs/user-input/smart-intent.js.map +1 -1
  32. package/lib/cjs/utils.d.ts +2 -1
  33. package/lib/cjs/utils.js +16 -3
  34. package/lib/cjs/utils.js.map +1 -1
  35. package/lib/esm/action/ai-agent.js +2 -0
  36. package/lib/esm/action/ai-agent.js.map +1 -1
  37. package/lib/esm/action/first-interaction.js +1 -1
  38. package/lib/esm/action/first-interaction.js.map +1 -1
  39. package/lib/esm/action/index.js +1 -1
  40. package/lib/esm/action/index.js.map +1 -1
  41. package/lib/esm/action/knowledge-bases.js +1 -1
  42. package/lib/esm/action/knowledge-bases.js.map +1 -1
  43. package/lib/esm/content-fields/flow-ai-agent.d.ts +3 -1
  44. package/lib/esm/content-fields/flow-ai-agent.js +5 -0
  45. package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
  46. package/lib/esm/content-fields/flow-whatsapp-template.d.ts +2 -1
  47. package/lib/esm/content-fields/flow-whatsapp-template.js +13 -5
  48. package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
  49. package/lib/esm/content-fields/hubtype-fields/ai-agent.d.ts +3 -0
  50. package/lib/esm/content-fields/hubtype-fields/whatsapp-template.d.ts +11 -8
  51. package/lib/esm/flow-factory.js +1 -1
  52. package/lib/esm/flow-factory.js.map +1 -1
  53. package/lib/esm/index.js +1 -1
  54. package/lib/esm/index.js.map +1 -1
  55. package/lib/esm/user-input/capture-user-input-api.d.ts +2 -1
  56. package/lib/esm/user-input/capture-user-input-api.js +6 -5
  57. package/lib/esm/user-input/capture-user-input-api.js.map +1 -1
  58. package/lib/esm/user-input/index.js +6 -4
  59. package/lib/esm/user-input/index.js.map +1 -1
  60. package/lib/esm/user-input/keyword.d.ts +4 -2
  61. package/lib/esm/user-input/keyword.js +5 -4
  62. package/lib/esm/user-input/keyword.js.map +1 -1
  63. package/lib/esm/user-input/smart-intent.d.ts +2 -2
  64. package/lib/esm/user-input/smart-intent.js +5 -5
  65. package/lib/esm/user-input/smart-intent.js.map +1 -1
  66. package/lib/esm/utils.d.ts +2 -1
  67. package/lib/esm/utils.js +16 -3
  68. package/lib/esm/utils.js.map +1 -1
  69. package/package.json +3 -3
  70. package/src/action/ai-agent.ts +2 -0
  71. package/src/action/first-interaction.ts +2 -2
  72. package/src/action/index.tsx +2 -2
  73. package/src/action/knowledge-bases.ts +2 -2
  74. package/src/content-fields/flow-ai-agent.tsx +5 -1
  75. package/src/content-fields/flow-whatsapp-template.tsx +26 -5
  76. package/src/content-fields/hubtype-fields/ai-agent.ts +3 -0
  77. package/src/content-fields/hubtype-fields/whatsapp-template.ts +13 -9
  78. package/src/flow-factory.ts +1 -1
  79. package/src/index.ts +2 -2
  80. package/src/user-input/capture-user-input-api.ts +12 -6
  81. package/src/user-input/index.ts +9 -7
  82. package/src/user-input/keyword.ts +10 -4
  83. package/src/user-input/smart-intent.ts +4 -4
  84. package/src/utils.ts +18 -2
@@ -7,14 +7,14 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
7
7
  const helpers_1 = require("../helpers");
8
8
  const tracking_1 = require("../tracking");
9
9
  class SmartIntentsApi {
10
- constructor(cmsApi, currentRequest, smartIntentsConfig, flowId) {
10
+ constructor(cmsApi, currentRequest, smartIntentsConfig, userTextOrTranscript) {
11
11
  this.cmsApi = cmsApi;
12
12
  this.currentRequest = currentRequest;
13
13
  this.smartIntentsConfig = smartIntentsConfig;
14
- this.flowId = flowId;
14
+ this.userTextOrTranscript = userTextOrTranscript;
15
15
  }
16
16
  async getNodeByInput() {
17
- if (!this.currentRequest.input.data) {
17
+ if (!this.userTextOrTranscript) {
18
18
  return undefined;
19
19
  }
20
20
  const smartIntentNodes = this.cmsApi.getSmartIntentNodes();
@@ -23,7 +23,7 @@ class SmartIntentsApi {
23
23
  }
24
24
  const params = {
25
25
  bot_id: this.currentRequest.session.bot.id,
26
- text: this.currentRequest.input.data,
26
+ text: this.userTextOrTranscript,
27
27
  num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
28
28
  use_latest: this.resolveUseLatest(),
29
29
  };
@@ -43,7 +43,7 @@ class SmartIntentsApi {
43
43
  nluIntentSmartTitle: response.data.smart_intent_title,
44
44
  nluIntentSmartNumUsed: response.data.smart_intents_used.length,
45
45
  nluIntentSmartMessageId: this.currentRequest.input.message_id,
46
- userInput: this.currentRequest.input.data,
46
+ userInput: this.userTextOrTranscript,
47
47
  flowThreadId: this.currentRequest.session.flow_thread_id,
48
48
  flowId,
49
49
  flowName,
@@ -1 +1 @@
1
- {"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";;;;AAAA,wCAA2E;AAE3E,0DAAyB;AAIzB,wCAAiD;AACjD,0CAGoB;AAepB,MAAa,eAAe;IAC1B,YACS,MAAsB,EACtB,cAA6B,EAC7B,kBAA+C,EAC/C,MAAe;QAHf,WAAM,GAAN,MAAM,CAAgB;QACtB,mBAAc,GAAd,cAAc,CAAe;QAC7B,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,WAAM,GAAN,MAAM,CAAS;IACrB,CAAC;IAEJ,KAAK,CAAC,cAAc;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAA;QAC1D,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,MAAM,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1C,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;YACpC,wBAAwB,EAAE,IAAI,CAAC,kBAAkB,CAAC,oBAAoB;YACtE,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE;SACpC,CAAA;QAED,IA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,OAAO,MAAM,IAAA,eAAK,EAAC;YACjB,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0CAA0C;YAC7E,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,KAAK;SACf,CAAC,CAAA;IACJ,CAAC;CACF;AA7FD,0CA6FC"}
@@ -1,7 +1,8 @@
1
1
  import { type Input, type Session } from '@botonic/core';
2
2
  import type { ActionRequest } from '@botonic/react';
3
3
  export declare function resolveGetAccessToken(getAccessToken: (session: Session) => string): (session: Session) => string;
4
- export declare function inputHasTextData(input: Input): boolean;
4
+ export declare function inputHasTextOrTranscript(input: Input): boolean;
5
+ export declare function getTextOrTranscript(input: Input): string | undefined;
5
6
  export declare function isKeywordsAllowed(request: ActionRequest): boolean;
6
7
  export declare function isSmartIntentsAllowed(request: ActionRequest): boolean;
7
8
  export declare function isKnowledgeBasesAllowed(request: ActionRequest): boolean;
package/lib/esm/utils.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveGetAccessToken = resolveGetAccessToken;
4
- exports.inputHasTextData = inputHasTextData;
4
+ exports.inputHasTextOrTranscript = inputHasTextOrTranscript;
5
+ exports.getTextOrTranscript = getTextOrTranscript;
5
6
  exports.isKeywordsAllowed = isKeywordsAllowed;
6
7
  exports.isSmartIntentsAllowed = isSmartIntentsAllowed;
7
8
  exports.isKnowledgeBasesAllowed = isKnowledgeBasesAllowed;
@@ -24,8 +25,20 @@ function resolveGetAccessToken(getAccessToken) {
24
25
  throw new Error('No method defined for getting access token');
25
26
  }
26
27
  }
27
- function inputHasTextData(input) {
28
- return input.data !== undefined && input.type === core_1.INPUT.TEXT;
28
+ function inputHasTextOrTranscript(input) {
29
+ const isTextInput = Boolean(input.data) && input.type === core_1.INPUT.TEXT;
30
+ const isTranscriptText = Boolean(input.transcript) && input.type === core_1.INPUT.AUDIO;
31
+ return isTextInput || isTranscriptText;
32
+ }
33
+ function getTextOrTranscript(input) {
34
+ if (input.type === core_1.INPUT.TEXT && input.data) {
35
+ return input.data;
36
+ }
37
+ if (input.type === core_1.INPUT.AUDIO && input.transcript) {
38
+ return input.transcript;
39
+ }
40
+ console.error('No text or transcript found in input', input);
41
+ return undefined;
29
42
  }
30
43
  function isNluAllowed(request, nluFlag) {
31
44
  const shadowing = Boolean(request.session._shadowing);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;AAaA,sDAWC;AAED,4CAEC;AAWD,8CAEC;AAED,sDAEC;AAED,0DAEC;AAjDD,wCAA+D;AAG/D,uCAAgD;AAChD,mCAAoE;AAEpE,SAAS,yBAAyB,CAAC,OAAgB;IACjD,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,OAAO,CAAC,aAAa,CAAA;AAC9B,CAAC;AAED,SAAgB,qBAAqB,CACnC,cAA4C;IAE5C,QAAQ,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC7B,KAAK,0BAAkB,CAAC,UAAU;YAChC,OAAO,yBAAyB,CAAA;QAClC,KAAK,0BAAkB,CAAC,WAAW;YACjC,OAAO,cAAc,CAAA;QACvB;YACE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;IACjE,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAY;IAC3C,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,YAAK,CAAC,IAAI,CAAA;AAC9D,CAAC;AAED,SAAS,YAAY,CACnB,OAAsB,EACtB,OAAgC;IAEhC,MAAM,SAAS,GAAG,OAAO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AAgB,uBAAuB,CAAC,OAAsB;IAC5D,OAAO,YAAY,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAA;AACrD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-flow-builder",
3
- "version": "0.45.0-alpha.1",
3
+ "version": "0.46.0-alpha.0",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "description": "Use Flow Builder to show your contents",
@@ -15,8 +15,8 @@
15
15
  "format": "biome format --write src/ tests/"
16
16
  },
17
17
  "dependencies": {
18
- "@botonic/react": "^0.45.0-alpha.1",
19
- "axios": "^1.13.2",
18
+ "@botonic/react": "^0.46.0-alpha.0",
19
+ "axios": "^1.13.6",
20
20
  "uuid": "^10.0.0"
21
21
  },
22
22
  "repository": {
@@ -47,6 +47,8 @@ export async function getContentsByAiAgent({
47
47
  {
48
48
  name: aiAgentContent.name,
49
49
  instructions: aiAgentContent.instructions,
50
+ model: aiAgentContent.model,
51
+ verbosity: aiAgentContent.verbosity,
50
52
  activeTools: aiAgentContent.activeTools,
51
53
  inputGuardrailRules: activeInputGuardrailRules,
52
54
  sourceIds: aiAgentContent.sources?.map(source => source.id),
@@ -2,7 +2,7 @@ import type { FlowBuilderApi } from '../api'
2
2
  import { MAIN_FLOW_NAME } from '../constants'
3
3
  import { FlowBotAction, type FlowContent } from '../content-fields'
4
4
  import type BotonicPluginFlowBuilder from '../index'
5
- import { inputHasTextData } from '../utils'
5
+ import { inputHasTextOrTranscript } from '../utils'
6
6
  import { getContentsByAiAgent } from './ai-agent'
7
7
  import type { FlowBuilderContext } from './index'
8
8
  import { getContentsByKnowledgeBase } from './knowledge-bases'
@@ -44,7 +44,7 @@ export async function getContentsByFirstInteraction(
44
44
  return firstInteractionContents
45
45
  }
46
46
 
47
- if (request.input.nluResolution || inputHasTextData(request.input)) {
47
+ if (request.input.nluResolution || inputHasTextOrTranscript(request.input)) {
48
48
  const contentsByUserInput = await getContentsByUserInput(context)
49
49
 
50
50
  return [...firstInteractionContents, ...contentsByUserInput]
@@ -15,7 +15,7 @@ import { FlowBotAction } from '../content-fields/flow-bot-action'
15
15
  import { ContentFilterExecutor } from '../filters'
16
16
  import { getFlowBuilderPlugin } from '../helpers'
17
17
  import type BotonicPluginFlowBuilder from '../index'
18
- import { inputHasTextData } from '../utils'
18
+ import { inputHasTextOrTranscript } from '../utils'
19
19
  import { getContentsByAiAgent } from './ai-agent'
20
20
  import { getContentsByFallback } from './fallback'
21
21
  import { getContentsByFirstInteraction } from './first-interaction'
@@ -147,7 +147,7 @@ async function getContents(
147
147
  return await getContentsByFallback(context)
148
148
  }
149
149
 
150
- if (inputHasTextData(request.input)) {
150
+ if (inputHasTextOrTranscript(request.input)) {
151
151
  const aiAgentContents = await getContentsByAiAgent(context)
152
152
  if (aiAgentContents.length > 0) {
153
153
  return aiAgentContents
@@ -17,7 +17,7 @@ import {
17
17
  trackEvent,
18
18
  } from '../tracking'
19
19
  import type { KnowledgeBaseFunction } from '../types'
20
- import { inputHasTextData, isKnowledgeBasesAllowed } from '../utils'
20
+ import { inputHasTextOrTranscript, isKnowledgeBasesAllowed } from '../utils'
21
21
  import type { FlowBuilderContext } from './index'
22
22
 
23
23
  export async function getContentsByKnowledgeBase({
@@ -49,7 +49,7 @@ export async function getContentsByKnowledgeBase({
49
49
 
50
50
  if (
51
51
  flowBuilderPlugin.getKnowledgeBaseResponse &&
52
- inputHasTextData(request.input) &&
52
+ inputHasTextOrTranscript(request.input) &&
53
53
  sourceIds.length > 0
54
54
  ) {
55
55
  const contentsWithKnowledgeResponse =
@@ -1,4 +1,4 @@
1
- import type { AgenticOutputMessage } from '@botonic/core'
1
+ import { type AgenticOutputMessage, VerbosityLevel } from '@botonic/core'
2
2
  import type { ActionRequest } from '@botonic/react'
3
3
 
4
4
  import { trackOneContent } from '../tracking'
@@ -13,6 +13,8 @@ import type {
13
13
  export class FlowAiAgent extends ContentFieldsBase {
14
14
  public name: string = ''
15
15
  public instructions: string = ''
16
+ public model: string = ''
17
+ public verbosity: VerbosityLevel = VerbosityLevel.Medium
16
18
  public activeTools?: { name: string }[]
17
19
  public inputGuardrailRules: HtInputGuardrailRule[]
18
20
  public sources?: { id: string; name: string }[]
@@ -24,6 +26,8 @@ export class FlowAiAgent extends ContentFieldsBase {
24
26
  newAiAgent.code = component.code
25
27
  newAiAgent.name = component.content.name
26
28
  newAiAgent.instructions = component.content.instructions
29
+ newAiAgent.model = component.content.model
30
+ newAiAgent.verbosity = component.content.verbosity
27
31
  newAiAgent.activeTools = component.content.active_tools
28
32
  newAiAgent.inputGuardrailRules =
29
33
  component.content.input_guardrail_rules || []
@@ -24,6 +24,7 @@ import type {
24
24
  HtWhatsAppTemplate,
25
25
  HtWhatsAppTemplateButtonsComponent,
26
26
  HtWhatsAppTemplateHeaderComponent,
27
+ HtWhatsappTemplateContentByLocale,
27
28
  HtWhatsappTemplateNode,
28
29
  } from './hubtype-fields'
29
30
 
@@ -41,21 +42,41 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
41
42
  public urlVariableValues?: Record<string, string>
42
43
 
43
44
  static fromHubtypeCMS(
44
- component: HtWhatsappTemplateNode
45
+ component: HtWhatsappTemplateNode,
46
+ currentLocale: string
45
47
  ): FlowWhatsappTemplate {
46
48
  const whatsappTemplate = new FlowWhatsappTemplate(component.id)
47
49
  whatsappTemplate.code = component.code
48
- whatsappTemplate.htWhatsappTemplate = component.content.template
49
- whatsappTemplate.headerVariables = component.content.header_variables
50
- whatsappTemplate.variableValues = component.content.variable_values
51
50
  whatsappTemplate.buttons = component.content.buttons
52
- whatsappTemplate.urlVariableValues = component.content.url_variable_values
51
+ const contentByLocale = FlowWhatsappTemplate.getContentByLocale(
52
+ component,
53
+ currentLocale
54
+ )
55
+
56
+ whatsappTemplate.htWhatsappTemplate = contentByLocale.template
57
+ whatsappTemplate.headerVariables = contentByLocale.header_variables
58
+ whatsappTemplate.variableValues = contentByLocale.variable_values
59
+ whatsappTemplate.urlVariableValues = contentByLocale.url_variable_values
53
60
 
54
61
  whatsappTemplate.followUp = component.follow_up
55
62
 
56
63
  return whatsappTemplate
57
64
  }
58
65
 
66
+ private static getContentByLocale(
67
+ component: HtWhatsappTemplateNode,
68
+ currentLocale: string
69
+ ) {
70
+ const content: HtWhatsappTemplateContentByLocale | undefined =
71
+ component.content.by_locale[currentLocale]
72
+ if (!content) {
73
+ throw new Error(
74
+ `Whatsapp template content not found for locale: ${currentLocale}`
75
+ )
76
+ }
77
+ return content
78
+ }
79
+
59
80
  private getHeaderComponent(
60
81
  whatsappTemplate: HtWhatsAppTemplate,
61
82
  headerVariables: HeaderVariables,
@@ -1,3 +1,4 @@
1
+ import type { VerbosityLevel } from '@botonic/core'
1
2
  import type { HtBaseNode } from './common'
2
3
  import type { HtNodeWithContentType } from './node-types'
3
4
 
@@ -12,6 +13,8 @@ export interface HtAiAgentNode extends HtBaseNode {
12
13
  content: {
13
14
  name: string
14
15
  instructions: string
16
+ model: string
17
+ verbosity: VerbosityLevel
15
18
  active_tools?: { name: string }[]
16
19
  input_guardrail_rules?: HtInputGuardrailRule[]
17
20
  sources?: { id: string; name: string }[]
@@ -69,18 +69,22 @@ export interface HtWhatsAppTemplate {
69
69
  namespace: string
70
70
  parameter_format: string
71
71
  }
72
+
73
+ export interface HtWhatsappTemplateContentByLocale {
74
+ template: HtWhatsAppTemplate
75
+ header_variables?: {
76
+ type: WhatsAppTemplateParameterType
77
+ text?: Record<string, string>
78
+ media?: HtMediaFileLocale[]
79
+ }
80
+ variable_values: Record<string, string>
81
+ url_variable_values?: Record<string, string>
82
+ }
83
+
72
84
  export interface HtWhatsappTemplateNode extends HtBaseNode {
73
85
  type: HtNodeWithContentType.WHATSAPP_TEMPLATE
74
86
  content: {
75
- template: HtWhatsAppTemplate
76
- header_variables?: {
77
- type: WhatsAppTemplateParameterType
78
- text?: Record<string, string>
79
- media?: HtMediaFileLocale[]
80
- }
81
- variable_values: Record<string, string>
82
-
87
+ by_locale: Record<string, HtWhatsappTemplateContentByLocale>
83
88
  buttons: HtButton[]
84
- url_variable_values?: Record<string, string>
85
89
  }
86
90
  }
@@ -93,7 +93,7 @@ export class FlowFactory {
93
93
  return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi)
94
94
 
95
95
  case HtNodeWithContentType.WHATSAPP_TEMPLATE:
96
- return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent)
96
+ return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale)
97
97
 
98
98
  case HtNodeWithContentType.CAPTURE_USER_INPUT:
99
99
  return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)
package/src/index.ts CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  } from './types'
39
39
  import { getNextPayloadByUserInput } from './user-input'
40
40
  import type { SmartIntentsInferenceConfig } from './user-input/smart-intent'
41
- import { inputHasTextData, resolveGetAccessToken } from './utils'
41
+ import { inputHasTextOrTranscript, resolveGetAccessToken } from './utils'
42
42
 
43
43
  // TODO: Create a proper service to wrap all calls and allow api versioning
44
44
 
@@ -109,7 +109,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
109
109
  })
110
110
 
111
111
  const checkUserTextInput =
112
- inputHasTextData(request.input) && !request.input.payload
112
+ inputHasTextOrTranscript(request.input) && !request.input.payload
113
113
 
114
114
  if (checkUserTextInput) {
115
115
  const resolvedLocale = this.cmsApi.getResolvedLocale()
@@ -13,7 +13,7 @@ import {
13
13
  getCommonFlowContentEventArgsForContentId,
14
14
  trackEvent,
15
15
  } from '../tracking'
16
- import { inputHasTextData } from '../utils'
16
+ import { inputHasTextOrTranscript } from '../utils'
17
17
 
18
18
  interface AiCaptureResponseSuccess {
19
19
  success: true
@@ -29,19 +29,25 @@ type AiCaptureResponse = AiCaptureResponseSuccess | AiCaptureResponseFailure
29
29
  export class CaptureUserInputApi {
30
30
  private cmsApi: FlowBuilderApi
31
31
  private request: ActionRequest
32
+ private textOrTranscript: string
32
33
 
33
- constructor(cmsApi: FlowBuilderApi, request: ActionRequest) {
34
+ constructor(
35
+ cmsApi: FlowBuilderApi,
36
+ request: ActionRequest,
37
+ textOrTranscript: string
38
+ ) {
34
39
  this.cmsApi = cmsApi
35
40
  this.request = request
41
+ this.textOrTranscript = textOrTranscript
36
42
  }
37
43
 
38
44
  async getNextNodeId(): Promise<string | undefined> {
39
45
  if (
40
- inputHasTextData(this.request.input) &&
46
+ inputHasTextOrTranscript(this.request.input) &&
41
47
  this.cmsApi.shouldCaptureUserInput()
42
48
  ) {
43
49
  const captureUserInputNode = this.cmsApi.getCaptureUserInputNode()
44
- if (!captureUserInputNode) {
50
+ if (!captureUserInputNode || !this.textOrTranscript) {
45
51
  return undefined
46
52
  }
47
53
  const captureUserInput =
@@ -50,7 +56,7 @@ export class CaptureUserInputApi {
50
56
  if (captureUserInput.aiValidationType === HtAiValidationType.NONE) {
51
57
  this.cmsApi.setUserExtraDataVariable(
52
58
  captureUserInputNode.content.field_name,
53
- this.request.input.data as string
59
+ this.textOrTranscript
54
60
  )
55
61
  await this.trackUserInputCapture(captureUserInputNode, true)
56
62
  return captureUserInput.captureSuccessId
@@ -82,7 +88,7 @@ export class CaptureUserInputApi {
82
88
  field_name: captureUserInputNode.content.field_name,
83
89
  validation_instructions:
84
90
  captureUserInputNode.content.ai_validation_instructions,
85
- user_input: this.request.input.data,
91
+ user_input: this.textOrTranscript,
86
92
  }
87
93
  const pluginFlowBuilder = getFlowBuilderPlugin(this.request.plugins)
88
94
  const token = pluginFlowBuilder.getAccessToken(this.request.session)
@@ -2,7 +2,7 @@ import type { ActionRequest } from '@botonic/react'
2
2
 
3
3
  import type { FlowBuilderApi } from '../api'
4
4
  import {
5
- inputHasTextData,
5
+ getTextOrTranscript,
6
6
  isKeywordsAllowed,
7
7
  isSmartIntentsAllowed,
8
8
  } from '../utils'
@@ -19,11 +19,13 @@ export async function getNextPayloadByUserInput(
19
19
  request: ActionRequest,
20
20
  smartIntentsConfig: SmartIntentsInferenceConfig
21
21
  ): Promise<string | undefined> {
22
- if (inputHasTextData(request.input)) {
22
+ const userTextOrTranscript = getTextOrTranscript(request.input)
23
+ if (userTextOrTranscript) {
23
24
  if (cmsApi.shouldCaptureUserInput()) {
24
25
  const captureUserInputApi = new CaptureUserInputApi(
25
26
  cmsApi,
26
- request as unknown as ActionRequest
27
+ request,
28
+ userTextOrTranscript
27
29
  )
28
30
  return await captureUserInputApi.getNextNodeId()
29
31
  }
@@ -33,10 +35,9 @@ export async function getNextPayloadByUserInput(
33
35
  cmsApi,
34
36
  locale,
35
37
  request,
38
+ userTextOrTranscript,
36
39
  })
37
- const keywordNode = await keywordMatcher.getNodeByInput(
38
- request.input.data!
39
- )
40
+ const keywordNode = await keywordMatcher.getNodeByInput()
40
41
  if (keywordNode) {
41
42
  return cmsApi.getPayload(keywordNode.target)
42
43
  }
@@ -46,7 +47,8 @@ export async function getNextPayloadByUserInput(
46
47
  const smartIntentsApi = new SmartIntentsApi(
47
48
  cmsApi,
48
49
  request,
49
- smartIntentsConfig
50
+ smartIntentsConfig,
51
+ userTextOrTranscript
50
52
  )
51
53
  const smartIntentNode = await smartIntentsApi.getNodeByInput()
52
54
  if (smartIntentNode) {
@@ -16,6 +16,7 @@ interface KeywordProps {
16
16
  cmsApi: FlowBuilderApi
17
17
  locale: string
18
18
  request: ActionRequest
19
+ userTextOrTranscript: string
19
20
  }
20
21
  export class KeywordMatcher {
21
22
  public cmsApi: FlowBuilderApi
@@ -25,17 +26,22 @@ export class KeywordMatcher {
25
26
  public matchedKeyword?: string
26
27
  public keywordNodeId?: string
27
28
  public flowId?: string
29
+ public userTextOrTranscript: string
28
30
 
29
- constructor({ cmsApi, locale, request }: KeywordProps) {
31
+ constructor({ cmsApi, locale, request, userTextOrTranscript }: KeywordProps) {
30
32
  this.cmsApi = cmsApi
31
33
  this.locale = locale
32
34
  this.request = request
33
35
  this.isRegExp = false
36
+ this.userTextOrTranscript = userTextOrTranscript
34
37
  }
35
38
 
36
- async getNodeByInput(userInput: string): Promise<HtKeywordNode | undefined> {
39
+ async getNodeByInput(): Promise<HtKeywordNode | undefined> {
37
40
  const keywordNodes = this.cmsApi.getKeywordNodes()
38
- const keywordNode = this.getNodeByKeyword(userInput, keywordNodes)
41
+ const keywordNode = this.getNodeByKeyword(
42
+ this.userTextOrTranscript,
43
+ keywordNodes
44
+ )
39
45
  if (!keywordNode || !this.matchedKeyword) {
40
46
  return undefined
41
47
  }
@@ -120,7 +126,7 @@ export class KeywordMatcher {
120
126
  nluKeywordName: this.matchedKeyword as string,
121
127
  nluKeywordIsRegex: this.isRegExp,
122
128
  nluKeywordMessageId: this.request.input.message_id,
123
- userInput: this.request.input.data as string,
129
+ userInput: this.userTextOrTranscript,
124
130
  }
125
131
  const { action, ...eventArgs } = event
126
132
  await trackEvent(this.request, action, eventArgs)
@@ -28,11 +28,11 @@ export class SmartIntentsApi {
28
28
  public cmsApi: FlowBuilderApi,
29
29
  public currentRequest: ActionRequest,
30
30
  public smartIntentsConfig: SmartIntentsInferenceConfig,
31
- public flowId?: string
31
+ public userTextOrTranscript: string
32
32
  ) {}
33
33
 
34
34
  async getNodeByInput(): Promise<HtSmartIntentNode | undefined> {
35
- if (!this.currentRequest.input.data) {
35
+ if (!this.userTextOrTranscript) {
36
36
  return undefined
37
37
  }
38
38
  const smartIntentNodes = this.cmsApi.getSmartIntentNodes()
@@ -42,7 +42,7 @@ export class SmartIntentsApi {
42
42
 
43
43
  const params = {
44
44
  bot_id: this.currentRequest.session.bot.id,
45
- text: this.currentRequest.input.data,
45
+ text: this.userTextOrTranscript,
46
46
  num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
47
47
  use_latest: this.resolveUseLatest(),
48
48
  }
@@ -73,7 +73,7 @@ export class SmartIntentsApi {
73
73
  nluIntentSmartTitle: response.data.smart_intent_title,
74
74
  nluIntentSmartNumUsed: response.data.smart_intents_used.length,
75
75
  nluIntentSmartMessageId: this.currentRequest.input.message_id,
76
- userInput: this.currentRequest.input.data,
76
+ userInput: this.userTextOrTranscript,
77
77
  flowThreadId: this.currentRequest.session.flow_thread_id as string,
78
78
  flowId,
79
79
  flowName,
package/src/utils.ts CHANGED
@@ -24,8 +24,24 @@ export function resolveGetAccessToken(
24
24
  }
25
25
  }
26
26
 
27
- export function inputHasTextData(input: Input): boolean {
28
- return input.data !== undefined && input.type === INPUT.TEXT
27
+ export function inputHasTextOrTranscript(input: Input): boolean {
28
+ const isTextInput = Boolean(input.data) && input.type === INPUT.TEXT
29
+ const isTranscriptText =
30
+ Boolean(input.transcript) && input.type === INPUT.AUDIO
31
+
32
+ return isTextInput || isTranscriptText
33
+ }
34
+
35
+ export function getTextOrTranscript(input: Input): string | undefined {
36
+ if (input.type === INPUT.TEXT && input.data) {
37
+ return input.data
38
+ }
39
+ if (input.type === INPUT.AUDIO && input.transcript) {
40
+ return input.transcript
41
+ }
42
+
43
+ console.error('No text or transcript found in input', input)
44
+ return undefined
29
45
  }
30
46
 
31
47
  function isNluAllowed(