diff --git a/packages/botonic-core/CHANGELOG.md b/packages/botonic-core/CHANGELOG.md index a0640845d1..e9be1356b1 100644 --- a/packages/botonic-core/CHANGELOG.md +++ b/packages/botonic-core/CHANGELOG.md @@ -19,3 +19,13 @@ All notable changes to Botonic will be documented in this file. ### Fixed + +## [0.32.0] - TBD + +### Added + +- [BLT-1369](https://hubtype.atlassian.net/browse/BLT-1369): Add new `SubscribeHelpdeskEvents` event `InitialQueuePosition`. + +### Changed + +### Fixed diff --git a/packages/botonic-core/package.json b/packages/botonic-core/package.json index ec4f588004..ee9784283d 100644 --- a/packages/botonic-core/package.json +++ b/packages/botonic-core/package.json @@ -1,6 +1,6 @@ { "name": "@botonic/core", - "version": "0.31.1", + "version": "0.32.0-alpha.0", "license": "MIT", "description": "Build Chatbots using React", "main": "./lib/cjs/index.js", diff --git a/packages/botonic-core/src/handoff.ts b/packages/botonic-core/src/handoff.ts index 93b50f082c..6959e27538 100644 --- a/packages/botonic-core/src/handoff.ts +++ b/packages/botonic-core/src/handoff.ts @@ -37,6 +37,7 @@ interface BotEventData { export enum HelpdeskEvent { StatusChanged = 'status_changed', AgentMessageCreated = 'agent_message_created', + InitialQueuePosition = 'initial_queue_position', } function contextDefaults(context: any): BackendContext { diff --git a/packages/botonic-core/src/models/legacy-types.ts b/packages/botonic-core/src/models/legacy-types.ts index 8da04bbacc..1d5a14da5d 100644 --- a/packages/botonic-core/src/models/legacy-types.ts +++ b/packages/botonic-core/src/models/legacy-types.ts @@ -73,6 +73,7 @@ export enum INPUT { WHATSAPP_BUTTON_LIST = 'whatsapp-button-list', WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button', EVENT_AGENT_MESSAGE_CREATED = 'case_event_agent_message_created', + EVENT_INITIAL_QUEUE_POSITION = 'case_event_initial_queue_position', WHATSAPP_CATALOG = 'whatsapp-catalog', WHATSAPP_PRODUCT = 'whatsapp-product', WHATSAPP_PRODUCT_LIST = 'whatsapp-product-list', @@ -120,6 +121,7 @@ export type InputType = | INPUT.WHATSAPP_BUTTON_LIST | INPUT.WHATSAPP_CTA_URL_BUTTON | INPUT.EVENT_AGENT_MESSAGE_CREATED + | INPUT.EVENT_INITIAL_QUEUE_POSITION | INPUT.WHATSAPP_CATALOG | INPUT.WHATSAPP_PRODUCT | INPUT.WHATSAPP_PRODUCT_LIST diff --git a/packages/botonic-core/tests/handoff.test.ts b/packages/botonic-core/tests/handoff.test.ts index 3100f0f8e3..2c155c4311 100644 --- a/packages/botonic-core/tests/handoff.test.ts +++ b/packages/botonic-core/tests/handoff.test.ts @@ -146,4 +146,12 @@ describe('Handoff', () => { const expectedBotonicAction = `${BotonicAction.CreateCase}:{"force_assign_if_not_available":true,"on_finish":"payload1","subscribe_helpdesk_events":["agent_message_created"]}` expect(builder._session._botonic_action).toEqual(expectedBotonicAction) }) + test('Create a handoff and subscribe to initial_queue_position', () => { + const builder = new HandOffBuilder({}) + .withSubscribeHelpdeskEvents([HelpdeskEvent.InitialQueuePosition]) + .withOnFinishPayload('payload1') + builder.handOff() + const expectedBotonicAction = `${BotonicAction.CreateCase}:{"force_assign_if_not_available":true,"on_finish":"payload1","subscribe_helpdesk_events":["initial_queue_position"]}` + expect(builder._session._botonic_action).toEqual(expectedBotonicAction) + }) }) diff --git a/packages/botonic-plugin-flow-builder/CHANGELOG.md b/packages/botonic-plugin-flow-builder/CHANGELOG.md index 225ad2ad0f..4b0b4d5d8c 100644 --- a/packages/botonic-plugin-flow-builder/CHANGELOG.md +++ b/packages/botonic-plugin-flow-builder/CHANGELOG.md @@ -20,6 +20,18 @@ All notable changes to Botonic will be documented in this file. +## [0.32.0] - TBD + +### Added + +- Add logic to conditionally [subscribe to `InitialQueuePosition` helpdesk event](https://github.com/hubtype/botonic/pull/2975) when doing a handoff. + +### Changed + +- Plugin endpoints to point to [new hubtype backend flow builder app](https://github.com/hubtype/botonic/pull/2972). + +### Fixed + ## [0.31.2] - 2025-02-07 ### Changed @@ -30,7 +42,7 @@ All notable changes to Botonic will be documented in this file. ### Changed -- Fix isLoading in useWebviewContents[https://github.com/hubtype/botonic/issues/2973](https://github.com/hubtype/botonic/pull/2973) +- Fix [isLoading in useWebviewContents](https://github.com/hubtype/botonic/pull/2973) ## [0.31.0] - 2025-01-22 diff --git a/packages/botonic-plugin-flow-builder/package.json b/packages/botonic-plugin-flow-builder/package.json index 81f3ecefe9..9d69bafbbd 100644 --- a/packages/botonic-plugin-flow-builder/package.json +++ b/packages/botonic-plugin-flow-builder/package.json @@ -1,6 +1,6 @@ { "name": "@botonic/plugin-flow-builder", - "version": "0.31.2", + "version": "0.32.0-alpha.1", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", "description": "Use Flow Builder to show your contents", @@ -14,7 +14,7 @@ "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'" }, "dependencies": { - "@botonic/react": "^0.31.0", + "@botonic/react": "0.32.0-alpha.0", "axios": "^1.7.9", "uuid": "^10.0.0" }, diff --git a/packages/botonic-plugin-flow-builder/src/action/index.tsx b/packages/botonic-plugin-flow-builder/src/action/index.tsx index 2abc48d266..ecd2f0dda1 100644 --- a/packages/botonic-plugin-flow-builder/src/action/index.tsx +++ b/packages/botonic-plugin-flow-builder/src/action/index.tsx @@ -1,3 +1,4 @@ +import { INPUT } from '@botonic/core' import { ActionRequest, Multichannel, RequestContext } from '@botonic/react' import React from 'react' @@ -82,6 +83,10 @@ async function getContents( if (request.session.is_first_interaction) { return await getContentsByFirstInteraction(context) } + // TODO: Add needed logic when we can define contents for multilocale queue position message + if (request.input.type === INPUT.EVENT_INITIAL_QUEUE_POSITION) { + return [] + } if (request.input.payload || contentID) { const contentsByPayload = await getContentsByPayload(context) diff --git a/packages/botonic-plugin-flow-builder/src/content-fields/flow-handoff.tsx b/packages/botonic-plugin-flow-builder/src/content-fields/flow-handoff.tsx index 5ec45cf418..26bb2faaf7 100644 --- a/packages/botonic-plugin-flow-builder/src/content-fields/flow-handoff.tsx +++ b/packages/botonic-plugin-flow-builder/src/content-fields/flow-handoff.tsx @@ -1,4 +1,4 @@ -import { HandOffBuilder, isDev, isWebchat } from '@botonic/core' +import { HandOffBuilder, HelpdeskEvent, isDev, isWebchat } from '@botonic/core' import { ActionRequest, Multichannel, @@ -16,6 +16,7 @@ export class FlowHandoff extends ContentFieldsBase { public queue?: HtQueueLocale public onFinishPayload?: string public handoffAutoAssign: boolean + public hasInitialQueuePositionEnabled: boolean public isTestIntegration: boolean static fromHubtypeCMS( @@ -28,7 +29,8 @@ export class FlowHandoff extends ContentFieldsBase { newHandoff.queue = this.getQueueByLocale(locale, cmsHandoff.content.queue) newHandoff.onFinishPayload = this.getOnFinishPayload(cmsHandoff, cmsApi) newHandoff.handoffAutoAssign = cmsHandoff.content.has_auto_assign - + newHandoff.hasInitialQueuePositionEnabled = + cmsHandoff.content.has_initial_queue_position_enabled return newHandoff } @@ -47,6 +49,12 @@ export class FlowHandoff extends ContentFieldsBase { const handOffBuilder = new HandOffBuilder(request.session) handOffBuilder.withAutoAssignOnWaiting(this.handoffAutoAssign) + if (this.hasInitialQueuePositionEnabled) { + handOffBuilder.withSubscribeHelpdeskEvents([ + HelpdeskEvent.InitialQueuePosition, + ]) + } + if (this.onFinishPayload) { handOffBuilder.withOnFinishPayload(this.onFinishPayload) } diff --git a/packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/handoff.ts b/packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/handoff.ts index b3c8eb41bf..4217d7f7ce 100644 --- a/packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/handoff.ts +++ b/packages/botonic-plugin-flow-builder/src/content-fields/hubtype-fields/handoff.ts @@ -7,5 +7,6 @@ export interface HtHandoffNode extends HtBaseNode { queue: HtQueueLocale[] payload: HtPayloadLocale[] has_auto_assign: boolean + has_initial_queue_position_enabled: boolean } } diff --git a/packages/botonic-plugin-flow-builder/tests/helpers/flows/basic.ts b/packages/botonic-plugin-flow-builder/tests/helpers/flows/basic.ts index 226acf330f..6b6e8f9aa1 100644 --- a/packages/botonic-plugin-flow-builder/tests/helpers/flows/basic.ts +++ b/packages/botonic-plugin-flow-builder/tests/helpers/flows/basic.ts @@ -550,6 +550,7 @@ export const basicFlow = { ], payload: [], has_auto_assign: false, + has_initial_queue_position_enabled: false, }, }, { diff --git a/packages/botonic-plugin-flow-builder/tests/helpers/flows/knowledge-base.ts b/packages/botonic-plugin-flow-builder/tests/helpers/flows/knowledge-base.ts index 662196f674..b79c6fd7c2 100644 --- a/packages/botonic-plugin-flow-builder/tests/helpers/flows/knowledge-base.ts +++ b/packages/botonic-plugin-flow-builder/tests/helpers/flows/knowledge-base.ts @@ -258,6 +258,7 @@ export const knowledgeBaseTestFlow = { ], payload: [], has_auto_assign: false, + has_initial_queue_position_enabled: false, }, }, { diff --git a/packages/botonic-react/package.json b/packages/botonic-react/package.json index 73676dabb0..74b680d935 100644 --- a/packages/botonic-react/package.json +++ b/packages/botonic-react/package.json @@ -1,6 +1,6 @@ { "name": "@botonic/react", - "version": "0.31.1", + "version": "0.32.0-alpha.0", "license": "MIT", "description": "Build Chatbots using React", "main": "./lib/cjs", @@ -20,7 +20,7 @@ "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' --fix" }, "dependencies": { - "@botonic/core": "^0.31.1", + "@botonic/core": "0.32.0-alpha.0", "axios": "^1.7.9", "emoji-picker-react": "^4.12.0", "lodash.merge": "^4.6.2",