diff --git a/packages/botonic-plugin-flow-builder/src/action/knowledge-bases.ts b/packages/botonic-plugin-flow-builder/src/action/knowledge-bases.ts index a14d24c04..e872ff18e 100644 --- a/packages/botonic-plugin-flow-builder/src/action/knowledge-bases.ts +++ b/packages/botonic-plugin-flow-builder/src/action/knowledge-bases.ts @@ -126,5 +126,6 @@ async function trackKnowledgeBase( knowledgebaseSourcesIds, knowledgebaseChunksIds, knowledgebaseMessageId, + userInput: request.input.data, }) } diff --git a/packages/botonic-plugin-flow-builder/src/user-input/intent.ts b/packages/botonic-plugin-flow-builder/src/user-input/intent.ts index 0cf221ada..95913160e 100644 --- a/packages/botonic-plugin-flow-builder/src/user-input/intent.ts +++ b/packages/botonic-plugin-flow-builder/src/user-input/intent.ts @@ -31,6 +31,7 @@ async function trackIntentEvent( nluIntentConfidence: request.input.confidence, nluIntentThreshold: intentNode?.content.confidence, nluIntentMessageId: request.input.message_id, + userInput: request.input.data, } await trackEvent(request, EventAction.Intent, eventArgs) } diff --git a/packages/botonic-plugin-flow-builder/src/user-input/keyword.ts b/packages/botonic-plugin-flow-builder/src/user-input/keyword.ts index 874de3cb9..0115b7620 100644 --- a/packages/botonic-plugin-flow-builder/src/user-input/keyword.ts +++ b/packages/botonic-plugin-flow-builder/src/user-input/keyword.ts @@ -91,6 +91,7 @@ export class KeywordMatcher { nluKeywordName: this.matchedKeyword, nluKeywordIsRegex: this.isRegExp, nluKeywordMessageId: this.request.input.message_id, + userInput: this.request.input.data, } await trackEvent(this.request, EventAction.Keyword, eventArgs) } diff --git a/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts b/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts index 12493598e..e3980d3f0 100644 --- a/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts +++ b/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts @@ -48,6 +48,7 @@ export class SmartIntentsApi { nluIntentSmartTitle: response.data.smart_intent_title, nluIntentSmartNumUsed: response.data.smart_intents_used.length, nluIntentSmartMessageId: this.currentRequest.input.message_id, + userInput: this.currentRequest.input.data, }) return smartIntentNode } diff --git a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent-smart.ts b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent-smart.ts index 9a728752e..415ec02da 100644 --- a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent-smart.ts +++ b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent-smart.ts @@ -5,6 +5,7 @@ export class HtEventIntentSmart extends HtEvent { nlu_intent_smart_title: string nlu_intent_smart_num_used: number nlu_intent_smart_message_id: string + user_input: string constructor(event: EventIntentSmart, requestData: RequestData) { super(event, requestData) @@ -13,5 +14,6 @@ export class HtEventIntentSmart extends HtEvent { this.nlu_intent_smart_title = event.nluIntentSmartTitle this.nlu_intent_smart_num_used = event.nluIntentSmartNumUsed this.nlu_intent_smart_message_id = event.nluIntentSmartMessageId + this.user_input = event.userInput } } diff --git a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent.ts b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent.ts index 6441ebe93..50e2894d7 100644 --- a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent.ts +++ b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-intent.ts @@ -6,6 +6,7 @@ export class HtEventIntent extends HtEvent { nlu_intent_confidence: number nlu_intent_threshold: number nlu_intent_message_id: string + user_input: string constructor(event: EventIntent, requestData: RequestData) { super(event, requestData) @@ -15,5 +16,6 @@ export class HtEventIntent extends HtEvent { this.nlu_intent_confidence = event.nluIntentConfidence this.nlu_intent_threshold = event.nluIntentThreshold this.nlu_intent_message_id = event.nluIntentMessageId + this.user_input = event.userInput } } diff --git a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-keyword.ts b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-keyword.ts index d18db2ef5..4f5ea1302 100644 --- a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-keyword.ts +++ b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-keyword.ts @@ -6,6 +6,7 @@ export class HtEventKeyword extends HtEvent { nlu_keyword_name: string nlu_keyword_is_regex: boolean nlu_keyword_message_id: string + user_input: string constructor(event: EventKeyword, requestData: RequestData) { super(event, requestData) @@ -15,5 +16,6 @@ export class HtEventKeyword extends HtEvent { this.nlu_keyword_name = event.nluKeywordName this.nlu_keyword_is_regex = event.nluKeywordIsRegex || false this.nlu_keyword_message_id = event.nluKeywordMessageId + this.user_input = event.userInput } } diff --git a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-knowledge-base.ts b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-knowledge-base.ts index 09018186d..f1c9b7e85 100644 --- a/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-knowledge-base.ts +++ b/packages/botonic-plugin-hubtype-analytics/src/event-models/ht-event-knowledge-base.ts @@ -12,6 +12,7 @@ export class HtEventKnowledgeBase extends HtEvent { knowledgebase_sources_ids: string[] knowledgebase_chunks_ids: string[] knowledgebase_message_id: string + user_input: string constructor(event: EventKnowledgeBase, requestData: RequestData) { super(event, requestData) @@ -22,5 +23,6 @@ export class HtEventKnowledgeBase extends HtEvent { this.knowledgebase_sources_ids = event.knowledgebaseSourcesIds this.knowledgebase_chunks_ids = event.knowledgebaseChunksIds this.knowledgebase_message_id = event.knowledgebaseMessageId + this.user_input = event.userInput } } diff --git a/packages/botonic-plugin-hubtype-analytics/src/types.ts b/packages/botonic-plugin-hubtype-analytics/src/types.ts index 279109d16..7f44149eb 100644 --- a/packages/botonic-plugin-hubtype-analytics/src/types.ts +++ b/packages/botonic-plugin-hubtype-analytics/src/types.ts @@ -74,6 +74,7 @@ export interface EventIntent extends HtBaseEventProps { nluIntentConfidence: number nluIntentThreshold: number nluIntentMessageId: string + userInput: string } export interface EventKeyword extends HtBaseEventProps { @@ -82,6 +83,7 @@ export interface EventKeyword extends HtBaseEventProps { nluKeywordName: string nluKeywordIsRegex?: boolean nluKeywordMessageId: string + userInput: string } export interface EventIntentSmart extends HtBaseEventProps { @@ -89,6 +91,7 @@ export interface EventIntentSmart extends HtBaseEventProps { nluIntentSmartTitle: string nluIntentSmartNumUsed: number nluIntentSmartMessageId: string + userInput: string } export interface EventKnowledgeBase extends HtBaseEventProps { @@ -98,6 +101,7 @@ export interface EventKnowledgeBase extends HtBaseEventProps { knowledgebaseSourcesIds: string[] knowledgebaseChunksIds: string[] knowledgebaseMessageId: string + userInput: string } export enum KnowledgebaseFailReason { diff --git a/packages/botonic-plugin-hubtype-analytics/tests/event-intent-smart.test.ts b/packages/botonic-plugin-hubtype-analytics/tests/event-intent-smart.test.ts index 2a4b79918..8090d98b9 100644 --- a/packages/botonic-plugin-hubtype-analytics/tests/event-intent-smart.test.ts +++ b/packages/botonic-plugin-hubtype-analytics/tests/event-intent-smart.test.ts @@ -9,6 +9,7 @@ describe('Create nlu intent smart events', () => { nluIntentSmartTitle: 'ADD_A_BAG', nluIntentSmartNumUsed: 2, nluIntentSmartMessageId: 'messageId', + userInput: 'Add a bag', }) expect(htEvent).toEqual({ @@ -20,6 +21,7 @@ describe('Create nlu intent smart events', () => { nlu_intent_smart_title: 'ADD_A_BAG', nlu_intent_smart_num_used: 2, nlu_intent_smart_message_id: 'messageId', + user_input: 'Add a bag', type: EventType.BotEvent, }) }) diff --git a/packages/botonic-plugin-hubtype-analytics/tests/event-intent.test.ts b/packages/botonic-plugin-hubtype-analytics/tests/event-intent.test.ts index db90d37eb..ba6b9910b 100644 --- a/packages/botonic-plugin-hubtype-analytics/tests/event-intent.test.ts +++ b/packages/botonic-plugin-hubtype-analytics/tests/event-intent.test.ts @@ -10,6 +10,7 @@ describe('Create nlu intent classic events', () => { nluIntentConfidence: 0.7, nluIntentThreshold: 0.6, nluIntentMessageId: 'nluIntentMessageId', + userInput: 'Add a bag', }) expect(htEvent).toEqual({ @@ -22,6 +23,7 @@ describe('Create nlu intent classic events', () => { nlu_intent_confidence: 0.7, nlu_intent_threshold: 0.6, nlu_intent_message_id: 'nluIntentMessageId', + user_input: 'Add a bag', type: EventType.BotEvent, }) }) diff --git a/packages/botonic-plugin-hubtype-analytics/tests/event-keyword.test.ts b/packages/botonic-plugin-hubtype-analytics/tests/event-keyword.test.ts index ff143c015..ea4e7ca15 100644 --- a/packages/botonic-plugin-hubtype-analytics/tests/event-keyword.test.ts +++ b/packages/botonic-plugin-hubtype-analytics/tests/event-keyword.test.ts @@ -10,6 +10,7 @@ describe('Create nlu keyword events', () => { nluKeywordName: 'hello', nluKeywordIsRegex: false, nluKeywordMessageId: 'messageId', + userInput: 'hello', }) expect(htEvent).toEqual({ @@ -22,6 +23,7 @@ describe('Create nlu keyword events', () => { nlu_keyword_name: 'hello', nlu_keyword_is_regex: false, nlu_keyword_message_id: 'messageId', + user_input: 'hello', type: EventType.BotEvent, }) }) diff --git a/packages/botonic-plugin-hubtype-analytics/tests/event-knowledge-base.test.ts b/packages/botonic-plugin-hubtype-analytics/tests/event-knowledge-base.test.ts index d0a2b4ec5..e488b6e8a 100644 --- a/packages/botonic-plugin-hubtype-analytics/tests/event-knowledge-base.test.ts +++ b/packages/botonic-plugin-hubtype-analytics/tests/event-knowledge-base.test.ts @@ -15,6 +15,7 @@ describe('Create knowledge base events', () => { knowledgebaseSourcesIds: ['sourceId1', 'sourceId2'], knowledgebaseChunksIds: ['cunkId1', 'chunkId2', 'chunkId3'], knowledgebaseMessageId: 'knowledgebaseMessageId', + userInput: 'What is Flow Builder?', }) expect(htEvent).toEqual({ @@ -27,6 +28,7 @@ describe('Create knowledge base events', () => { knowledgebase_sources_ids: ['sourceId1', 'sourceId2'], knowledgebase_chunks_ids: ['cunkId1', 'chunkId2', 'chunkId3'], knowledgebase_message_id: 'knowledgebaseMessageId', + user_input: 'What is Flow Builder?', type: EventType.BotEvent, }) }) @@ -39,6 +41,7 @@ describe('Create knowledge base events', () => { knowledgebaseSourcesIds: ['sourceId1', 'sourceId2'], knowledgebaseChunksIds: ['cunkId1', 'chunkId2', 'chunkId3'], knowledgebaseMessageId: 'knowledgebaseMessageId', + userInput: 'What is Flow Builder?', }) expect(htEvent).toEqual({ @@ -52,6 +55,7 @@ describe('Create knowledge base events', () => { knowledgebase_sources_ids: ['sourceId1', 'sourceId2'], knowledgebase_chunks_ids: ['cunkId1', 'chunkId2', 'chunkId3'], knowledgebase_message_id: 'knowledgebaseMessageId', + user_input: 'What is Flow Builder?', type: EventType.BotEvent, }) })