From 8c16902fa1433803e2ec8c6d1f0d4b086b26facb Mon Sep 17 00:00:00 2001 From: Ryan Pope Date: Tue, 24 Sep 2024 16:59:23 -0400 Subject: [PATCH 1/6] chat-core-zendesk: add support for session reinitialization Adds support for restoring a Zendesk agent conversation using the conversation ID. Requires reinitialization of the Zendesk client, which can only be triggered on the first message sent after the new page is loaded. This leads to a slight bit of extra lag on that first message, but otherwise everything seems to work as if the page was never reloaded. TEST=manual Used this locally with upcoming chat-headless change to support this new method, saw expected results across page loads and within the Zendesk platform. --- .../chat-core-aws-connect/THIRD-PARTY-NOTICES | 2 +- ...hat-core-aws-connect.chatcoreawsconnect.md | 1 + .../etc/chat-core-aws-connect.api.md | 1 + .../src/infra/ChatCoreAwsConnectImpl.ts | 6 ++++++ .../src/models/ChatCoreAwsConnect.ts | 10 ++++++++++ .../docs/chat-core-zendesk.chatcorezendesk.md | 1 + .../etc/chat-core-zendesk.api.md | 1 + .../src/infra/ChatCoreZendeskImpl.ts | 19 ++++++++++++++++--- .../src/models/ChatCoreZendesk.ts | 7 +++++++ .../tests/ChatCoreZendesk.test.ts | 4 ++-- 10 files changed, 46 insertions(+), 6 deletions(-) diff --git a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES index 30fcf88..c96dc7e 100644 --- a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES +++ b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES @@ -195,7 +195,7 @@ The following NPM packages may be included in this product: - @types/istanbul-lib-report@3.0.3 - @types/istanbul-reports@3.0.4 - @types/jsdom@20.0.1 - - @types/node@22.5.5 + - @types/node@22.6.1 - @types/stack-utils@2.0.3 - @types/tough-cookie@4.0.5 - @types/yargs-parser@21.0.3 diff --git a/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.md b/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.md index 3858a0b..4bcb316 100644 --- a/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.md +++ b/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.md @@ -21,5 +21,6 @@ export interface ChatCoreAwsConnect | [init(messageResponse)](./chat-core-aws-connect.chatcoreawsconnect.init.md) | Initialize the Amazon Connect chat session using the credentials from the Chat API. | | [on(eventName, cb)](./chat-core-aws-connect.chatcoreawsconnect.on.md) | Register a callback for an event triggered within the Amazon Connect chat session. Supported events are: - message: A new message has been received. - typing: The agent is typing. - close: The chat session has been closed. | | [processMessage(request)](./chat-core-aws-connect.chatcoreawsconnect.processmessage.md) | Process a message sent by the user. | +| [reinitializeSession(\_)](./chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md) | Reinitialize the session using existing session data. | | [resetSession()](./chat-core-aws-connect.chatcoreawsconnect.resetsession.md) | Resets the [ChatCoreAwsConnect](./chat-core-aws-connect.chatcoreawsconnect.md) instance, clearing the underlying Amazon Connect session. | diff --git a/packages/chat-core-aws-connect/etc/chat-core-aws-connect.api.md b/packages/chat-core-aws-connect/etc/chat-core-aws-connect.api.md index e03b3f8..863fe0e 100644 --- a/packages/chat-core-aws-connect/etc/chat-core-aws-connect.api.md +++ b/packages/chat-core-aws-connect/etc/chat-core-aws-connect.api.md @@ -27,6 +27,7 @@ export interface ChatCoreAwsConnect { init(messageResponse: MessageResponse): Promise; on(eventName: T, cb: EventCallback): void; processMessage(request: MessageRequest): Promise; + reinitializeSession(_: unknown): Promise; resetSession(): void; } diff --git a/packages/chat-core-aws-connect/src/infra/ChatCoreAwsConnectImpl.ts b/packages/chat-core-aws-connect/src/infra/ChatCoreAwsConnectImpl.ts index 37cdf82..ed35b30 100644 --- a/packages/chat-core-aws-connect/src/infra/ChatCoreAwsConnectImpl.ts +++ b/packages/chat-core-aws-connect/src/infra/ChatCoreAwsConnectImpl.ts @@ -145,4 +145,10 @@ export class ChatCoreAwsConnectImpl implements ChatCoreAwsConnect { this.session.disconnectParticipant(); this.session = undefined; } + + async reinitializeSession(_: unknown): Promise { + console.warn( + "Reinitializing chat session is currently not supported for AWS Connect" + ); + } } diff --git a/packages/chat-core-aws-connect/src/models/ChatCoreAwsConnect.ts b/packages/chat-core-aws-connect/src/models/ChatCoreAwsConnect.ts index 465890e..ba15a65 100644 --- a/packages/chat-core-aws-connect/src/models/ChatCoreAwsConnect.ts +++ b/packages/chat-core-aws-connect/src/models/ChatCoreAwsConnect.ts @@ -55,4 +55,14 @@ export interface ChatCoreAwsConnect { * Resets the {@link ChatCoreAwsConnect} instance, clearing the underlying Amazon Connect session. */ resetSession(): void; + + /** + * Reinitialize the session using existing session data. + * + * @param credentials - The credentials to use to reinitialize the session. + * + * @remarks + * This is currently not supported for Amazon Connect. + */ + reinitializeSession(_: unknown): Promise; } diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.md index 5edf192..3c852f8 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.md @@ -21,5 +21,6 @@ export interface ChatCoreZendesk | [init(messageResponse)](./chat-core-zendesk.chatcorezendesk.init.md) | Initialize the Amazon Connect chat session using the credentials from the Chat API. | | [on(eventName, cb)](./chat-core-zendesk.chatcorezendesk.on.md) | Register a callback for an event triggered within the Zendesk chat session. Supported events are: - message: A new message has been received. - typing: The agent is typing. - close: The chat session has been closed (e.g. agent left or closed the ticket). | | [processMessage(request)](./chat-core-zendesk.chatcorezendesk.processmessage.md) | Process a message sent by the user. | +| [reinitializeSession(credentials)](./chat-core-zendesk.chatcorezendesk.reinitializesession.md) | Reinitialize the session using existing session data. | | [resetSession()](./chat-core-zendesk.chatcorezendesk.resetsession.md) | Reset the chat session by clearing the current conversation ID. | diff --git a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md index c476ef7..012e1cc 100644 --- a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md +++ b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md @@ -18,6 +18,7 @@ export interface ChatCoreZendesk { // Warning: (ae-forgotten-export) The symbol "EventCallback" needs to be exported by the entry point index.d.ts on(eventName: T, cb: EventCallback): void; processMessage(request: MessageRequest): Promise; + reinitializeSession(credentials: string): Promise; resetSession(): void; } diff --git a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts index 9a52750..9154c2a 100644 --- a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts +++ b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts @@ -63,7 +63,12 @@ export class ChatCoreZendeskImpl { * mode on the first invocation. Subsequent calls to this method will create a * new conversation session. */ - async init(messageRsp: MessageResponse): Promise { + async init(messageRsp: MessageResponse): Promise { + await this.initializeZendeskSdk(); + return await this.createZendeskConversation(messageRsp); + } + + private async initializeZendeskSdk(): Promise { const divId = "yext-chat-core-zendesk-container"; if (!window.document.getElementById(divId)) { const div = window.document.createElement("div"); @@ -83,7 +88,6 @@ export class ChatCoreZendeskImpl { } this.setupEventListeners(); } - await this.setupSession(messageRsp); } /** @@ -91,7 +95,9 @@ export class ChatCoreZendeskImpl { * On ticket creation, the metadata is set to include the tag "yext-chat" * with the conversation summary as the initial message. */ - private async setupSession(messageRsp: MessageResponse) { + private async createZendeskConversation( + messageRsp: MessageResponse + ): Promise { const ticketFields: Record = {}; try { if (messageRsp.integrationDetails?.zendeskHandoff?.ticketFields) { @@ -133,6 +139,7 @@ export class ChatCoreZendeskImpl { }`, this.conversationId ); + return this.conversationId; } private setupEventListeners() { @@ -210,4 +217,10 @@ export class ChatCoreZendeskImpl { resetSession(): void { this.conversationId = undefined; } + + async reinitializeSession(conversationId: string): Promise { + this.conversationId = conversationId; + await this.initializeZendeskSdk(); + await Smooch.loadConversation(conversationId); + } } diff --git a/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts b/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts index e02cb51..5b00719 100644 --- a/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts +++ b/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts @@ -52,4 +52,11 @@ export interface ChatCoreZendesk { * Reset the chat session by clearing the current conversation ID. */ resetSession(): void; + + /** + * Reinitialize the session using existing session data. + * + * @param credentials - The credentials to use to reinitialize the session. + */ + reinitializeSession(credentials: string): Promise; } diff --git a/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts b/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts index 71e2df9..57a0f00 100644 --- a/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts +++ b/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts @@ -58,11 +58,11 @@ describe("chat session initialization", () => { ); }); - it("returns no error when successfully connecting to chat session", async () => { + it("returns convo id and no error when successfully connecting to chat session", async () => { const chatCoreZendesk = provideChatCoreZendesk(mockConfig); await expect( chatCoreZendesk.init(mockMessageResponse()) - ).resolves.toBeUndefined(); + ).resolves.toBe("mock-conversation-id"); }); it("avoid rendering smooch web widget on subsequent initialization", async () => { From 9f2a3859bee7e044dc6f5bd6cd94939df4dea822 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 21:06:14 +0000 Subject: [PATCH 2/6] Automated update to repo's documentation and third party notices from github action --- ....chatcoreawsconnect.reinitializesession.md | 28 +++++++++++++++++++ ...esk.chatcorezendesk.reinitializesession.md | 24 ++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md create mode 100644 packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md diff --git a/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md b/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md new file mode 100644 index 0000000..906f3e5 --- /dev/null +++ b/packages/chat-core-aws-connect/docs/chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [@yext/chat-core-aws-connect](./chat-core-aws-connect.md) > [ChatCoreAwsConnect](./chat-core-aws-connect.chatcoreawsconnect.md) > [reinitializeSession](./chat-core-aws-connect.chatcoreawsconnect.reinitializesession.md) + +## ChatCoreAwsConnect.reinitializeSession() method + +Reinitialize the session using existing session data. + +**Signature:** + +```typescript +reinitializeSession(_: unknown): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| \_ | unknown | | + +**Returns:** + +Promise<void> + +## Remarks + +This is currently not supported for Amazon Connect. + diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md new file mode 100644 index 0000000..a939872 --- /dev/null +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@yext/chat-core-zendesk](./chat-core-zendesk.md) > [ChatCoreZendesk](./chat-core-zendesk.chatcorezendesk.md) > [reinitializeSession](./chat-core-zendesk.chatcorezendesk.reinitializesession.md) + +## ChatCoreZendesk.reinitializeSession() method + +Reinitialize the session using existing session data. + +**Signature:** + +```typescript +reinitializeSession(credentials: string): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| credentials | string | The credentials to use to reinitialize the session. | + +**Returns:** + +Promise<void> + From 62689ffc6c74f3040c2e013516b8a6a653c7bc81 Mon Sep 17 00:00:00 2001 From: Ryan Pope Date: Wed, 25 Sep 2024 17:01:55 -0400 Subject: [PATCH 3/6] address comments --- .../chat-core-aws-connect/THIRD-PARTY-NOTICES | 2 +- ...core-zendesk.chatcorezendesk.getsession.md | 4 ++-- .../chat-core-zendesk.chatcorezendesk.init.md | 4 ++-- ...esk.chatcorezendesk.reinitializesession.md | 4 ++-- .../etc/chat-core-zendesk.api.md | 7 +++--- .../src/infra/ChatCoreZendeskImpl.ts | 23 ++++++++++++------- .../src/models/ChatCoreZendesk.ts | 7 +++--- .../ChatCoreZendeskSessionCredentials.ts | 12 ++++++++++ 8 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 packages/chat-core-zendesk/src/models/ChatCoreZendeskSessionCredentials.ts diff --git a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES index c96dc7e..0701f4d 100644 --- a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES +++ b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES @@ -195,7 +195,7 @@ The following NPM packages may be included in this product: - @types/istanbul-lib-report@3.0.3 - @types/istanbul-reports@3.0.4 - @types/jsdom@20.0.1 - - @types/node@22.6.1 + - @types/node@22.7.1 - @types/stack-utils@2.0.3 - @types/tough-cookie@4.0.5 - @types/yargs-parser@21.0.3 diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.getsession.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.getsession.md index 60f06ff..d145ac4 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.getsession.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.getsession.md @@ -9,9 +9,9 @@ Provide the current conversation ID for the chat session. **Signature:** ```typescript -getSession(): void; +getSession(): string | undefined; ``` **Returns:** -void +string \| undefined diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md index 49a8f7b..5090391 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md @@ -9,7 +9,7 @@ Initialize the Amazon Connect chat session using the credentials from the Chat A **Signature:** ```typescript -init(messageResponse: MessageResponse): Promise; +init(messageResponse: MessageResponse): Promise; ``` ## Parameters @@ -20,5 +20,5 @@ init(messageResponse: MessageResponse): Promise; **Returns:** -Promise<void> +Promise<ChatCoreZendeskSessionCredentials> diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md index a939872..a246324 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md @@ -9,14 +9,14 @@ Reinitialize the session using existing session data. **Signature:** ```typescript -reinitializeSession(credentials: string): Promise; +reinitializeSession(credentials: ChatCoreZendeskSessionCredentials): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| credentials | string | The credentials to use to reinitialize the session. | +| credentials | ChatCoreZendeskSessionCredentials | The credentials to use to reinitialize the session. | **Returns:** diff --git a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md index 012e1cc..85c3f02 100644 --- a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md +++ b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md @@ -12,13 +12,14 @@ import { MessageResponse } from '@yext/chat-core'; // @public export interface ChatCoreZendesk { emit(eventName: T, data: EventMap[T]): void; - getSession(): void; - init(messageResponse: MessageResponse): Promise; + getSession(): string | undefined; + // Warning: (ae-forgotten-export) The symbol "ChatCoreZendeskSessionCredentials" needs to be exported by the entry point index.d.ts + init(messageResponse: MessageResponse): Promise; // Warning: (ae-forgotten-export) The symbol "EventMap" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "EventCallback" needs to be exported by the entry point index.d.ts on(eventName: T, cb: EventCallback): void; processMessage(request: MessageRequest): Promise; - reinitializeSession(credentials: string): Promise; + reinitializeSession(credentials: ChatCoreZendeskSessionCredentials): Promise; resetSession(): void; } diff --git a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts index 9154c2a..e4f1a5d 100644 --- a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts +++ b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ import { MessageRequest, MessageResponse } from "@yext/chat-core"; +import { ChatCoreZendesk } from "../models"; /** * Issue 1: Smooch Version @@ -32,6 +33,7 @@ const Smooch = (SmoochLib.default || SmoochLib) as typeof SmoochLib; import { ChatCoreZendeskConfig } from "../models/ChatCoreZendeskConfig"; import { EventCallback, EventMap } from "../models/EventCallback"; +import { ChatCoreZendeskSessionCredentials } from "../models/ChatCoreZendeskSessionCredentials"; const MetadataChatSDKKey = "YEXT_CHAT_SDK"; @@ -43,7 +45,7 @@ const MetadataChatSDKKey = "YEXT_CHAT_SDK"; * * @internal */ -export class ChatCoreZendeskImpl { +export class ChatCoreZendeskImpl implements ChatCoreZendesk { private eventListeners: { [T in keyof EventMap]?: EventCallback[] } = {}; private conversationId: string | undefined; private integrationId: string; @@ -63,9 +65,9 @@ export class ChatCoreZendeskImpl { * mode on the first invocation. Subsequent calls to this method will create a * new conversation session. */ - async init(messageRsp: MessageResponse): Promise { + async init(messageRsp: MessageResponse): Promise { await this.initializeZendeskSdk(); - return await this.createZendeskConversation(messageRsp); + return this.createZendeskConversation(messageRsp); } private async initializeZendeskSdk(): Promise { @@ -97,7 +99,7 @@ export class ChatCoreZendeskImpl { */ private async createZendeskConversation( messageRsp: MessageResponse - ): Promise { + ): Promise { const ticketFields: Record = {}; try { if (messageRsp.integrationDetails?.zendeskHandoff?.ticketFields) { @@ -139,7 +141,10 @@ export class ChatCoreZendeskImpl { }`, this.conversationId ); - return this.conversationId; + + return { + conversationId: convo.id, + }; } private setupEventListeners() { @@ -215,12 +220,14 @@ export class ChatCoreZendeskImpl { } resetSession(): void { + // @ts-ignore - off() is not in the Smooch types, but does exist + Smooch.off(); this.conversationId = undefined; } - async reinitializeSession(conversationId: string): Promise { - this.conversationId = conversationId; + async reinitializeSession(credentials: ChatCoreZendeskSessionCredentials): Promise { + this.conversationId = credentials.conversationId; await this.initializeZendeskSdk(); - await Smooch.loadConversation(conversationId); + await Smooch.loadConversation(credentials.conversationId); } } diff --git a/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts b/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts index 5b00719..8644f9a 100644 --- a/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts +++ b/packages/chat-core-zendesk/src/models/ChatCoreZendesk.ts @@ -1,5 +1,6 @@ import { MessageRequest, MessageResponse } from "@yext/chat-core"; import { EventCallback, EventMap } from "./EventCallback"; +import { ChatCoreZendeskSessionCredentials } from "./ChatCoreZendeskSessionCredentials"; /** * Provides methods for interacting with Chat's Zendesk integration. @@ -12,7 +13,7 @@ export interface ChatCoreZendesk { * * @param messageResponse - The response returned from a successful call to the Chat API. */ - init(messageResponse: MessageResponse): Promise; + init(messageResponse: MessageResponse): Promise; /** * Register a callback for an event triggered within the Zendesk chat session. @@ -46,7 +47,7 @@ export interface ChatCoreZendesk { /** * Provide the current conversation ID for the chat session. */ - getSession(): void; + getSession(): string | undefined; /** * Reset the chat session by clearing the current conversation ID. @@ -58,5 +59,5 @@ export interface ChatCoreZendesk { * * @param credentials - The credentials to use to reinitialize the session. */ - reinitializeSession(credentials: string): Promise; + reinitializeSession(credentials: ChatCoreZendeskSessionCredentials): Promise; } diff --git a/packages/chat-core-zendesk/src/models/ChatCoreZendeskSessionCredentials.ts b/packages/chat-core-zendesk/src/models/ChatCoreZendeskSessionCredentials.ts new file mode 100644 index 0000000..c147641 --- /dev/null +++ b/packages/chat-core-zendesk/src/models/ChatCoreZendeskSessionCredentials.ts @@ -0,0 +1,12 @@ +/** + * Credentials for the Zendesk session created by the {@link ChatCoreZendesk}. + * Used for reinitializing the session across page reloads. + * + * @public + */ +export interface ChatCoreZendeskSessionCredentials { + /** + * The conversation ID for the current chat session. + */ + conversationId: string; +} \ No newline at end of file From 4696f37b6b88ca463f6d7c489a72e5f2419eb254 Mon Sep 17 00:00:00 2001 From: Ryan Pope Date: Mon, 30 Sep 2024 15:57:13 -0400 Subject: [PATCH 4/6] fix test --- packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts b/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts index 57a0f00..02faa7a 100644 --- a/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts +++ b/packages/chat-core-zendesk/tests/ChatCoreZendesk.test.ts @@ -33,6 +33,7 @@ jest.mock("smooch", () => ({ on: jest.fn(), startTyping: jest.fn(), stopTyping: jest.fn(), + off: jest.fn(), })); beforeEach(() => { @@ -62,7 +63,7 @@ describe("chat session initialization", () => { const chatCoreZendesk = provideChatCoreZendesk(mockConfig); await expect( chatCoreZendesk.init(mockMessageResponse()) - ).resolves.toBe("mock-conversation-id"); + ).resolves.toStrictEqual({conversationId: "mock-conversation-id"}); }); it("avoid rendering smooch web widget on subsequent initialization", async () => { From 4da1b4b87d8d1f40281fc44012aaddedf8cfade6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:58:38 +0000 Subject: [PATCH 5/6] Automated update to repo's documentation and third party notices from github action --- packages/chat-core-aws-connect/THIRD-PARTY-NOTICES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES index 0701f4d..8e2741a 100644 --- a/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES +++ b/packages/chat-core-aws-connect/THIRD-PARTY-NOTICES @@ -195,7 +195,7 @@ The following NPM packages may be included in this product: - @types/istanbul-lib-report@3.0.3 - @types/istanbul-reports@3.0.4 - @types/jsdom@20.0.1 - - @types/node@22.7.1 + - @types/node@22.7.4 - @types/stack-utils@2.0.3 - @types/tough-cookie@4.0.5 - @types/yargs-parser@21.0.3 @@ -1863,7 +1863,7 @@ SOFTWARE. The following NPM package may be included in this product: - - nwsapi@2.2.12 + - nwsapi@2.2.13 This package contains the following license and notice below: From b5ed0360f689c0932a98278b9472c7eb217e4e08 Mon Sep 17 00:00:00 2001 From: Ryan Pope Date: Tue, 1 Oct 2024 13:44:00 -0400 Subject: [PATCH 6/6] fix export --- .../chat-core-zendesk.chatcorezendesk.init.md | 2 +- ...esk.chatcorezendesk.reinitializesession.md | 2 +- ...endesksessioncredentials.conversationid.md | 13 ++++++++++++ ...ndesk.chatcorezendesksessioncredentials.md | 20 +++++++++++++++++++ .../docs/chat-core-zendesk.md | 1 + .../etc/chat-core-zendesk.api.md | 6 +++++- .../chat-core-zendesk/src/models/index.ts | 1 + 7 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesksessioncredentials.conversationid.md create mode 100644 packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesksessioncredentials.md diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md index 5090391..d83cabd 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.init.md @@ -20,5 +20,5 @@ init(messageResponse: MessageResponse): Promise> diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md index a246324..eeae624 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesk.reinitializesession.md @@ -16,7 +16,7 @@ reinitializeSession(credentials: ChatCoreZendeskSessionCredentials): Promise + +[Home](./index.md) > [@yext/chat-core-zendesk](./chat-core-zendesk.md) > [ChatCoreZendeskSessionCredentials](./chat-core-zendesk.chatcorezendesksessioncredentials.md) > [conversationId](./chat-core-zendesk.chatcorezendesksessioncredentials.conversationid.md) + +## ChatCoreZendeskSessionCredentials.conversationId property + +The conversation ID for the current chat session. + +**Signature:** + +```typescript +conversationId: string; +``` diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesksessioncredentials.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesksessioncredentials.md new file mode 100644 index 0000000..ecaa78d --- /dev/null +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.chatcorezendesksessioncredentials.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [@yext/chat-core-zendesk](./chat-core-zendesk.md) > [ChatCoreZendeskSessionCredentials](./chat-core-zendesk.chatcorezendesksessioncredentials.md) + +## ChatCoreZendeskSessionCredentials interface + +Credentials for the Zendesk session created by the [ChatCoreZendesk](./chat-core-zendesk.chatcorezendesk.md). Used for reinitializing the session across page reloads. + +**Signature:** + +```typescript +export interface ChatCoreZendeskSessionCredentials +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [conversationId](./chat-core-zendesk.chatcorezendesksessioncredentials.conversationid.md) | | string | The conversation ID for the current chat session. | + diff --git a/packages/chat-core-zendesk/docs/chat-core-zendesk.md b/packages/chat-core-zendesk/docs/chat-core-zendesk.md index 9787d76..41cf1aa 100644 --- a/packages/chat-core-zendesk/docs/chat-core-zendesk.md +++ b/packages/chat-core-zendesk/docs/chat-core-zendesk.md @@ -16,4 +16,5 @@ | --- | --- | | [ChatCoreZendesk](./chat-core-zendesk.chatcorezendesk.md) | Provides methods for interacting with Chat's Zendesk integration. | | [ChatCoreZendeskConfig](./chat-core-zendesk.chatcorezendeskconfig.md) | Configuration for this instance of the [ChatCoreZendesk](./chat-core-zendesk.chatcorezendesk.md). | +| [ChatCoreZendeskSessionCredentials](./chat-core-zendesk.chatcorezendesksessioncredentials.md) | Credentials for the Zendesk session created by the [ChatCoreZendesk](./chat-core-zendesk.chatcorezendesk.md). Used for reinitializing the session across page reloads. | diff --git a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md index 85c3f02..128cae0 100644 --- a/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md +++ b/packages/chat-core-zendesk/etc/chat-core-zendesk.api.md @@ -13,7 +13,6 @@ import { MessageResponse } from '@yext/chat-core'; export interface ChatCoreZendesk { emit(eventName: T, data: EventMap[T]): void; getSession(): string | undefined; - // Warning: (ae-forgotten-export) The symbol "ChatCoreZendeskSessionCredentials" needs to be exported by the entry point index.d.ts init(messageResponse: MessageResponse): Promise; // Warning: (ae-forgotten-export) The symbol "EventMap" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "EventCallback" needs to be exported by the entry point index.d.ts @@ -29,6 +28,11 @@ export interface ChatCoreZendeskConfig { ticketTags?: string[]; } +// @public +export interface ChatCoreZendeskSessionCredentials { + conversationId: string; +} + // Warning: (ae-forgotten-export) The symbol "ChatCoreZendeskImpl" needs to be exported by the entry point index.d.ts // // @public diff --git a/packages/chat-core-zendesk/src/models/index.ts b/packages/chat-core-zendesk/src/models/index.ts index 0767bba..6ac772a 100644 --- a/packages/chat-core-zendesk/src/models/index.ts +++ b/packages/chat-core-zendesk/src/models/index.ts @@ -1,2 +1,3 @@ export { ChatCoreZendeskConfig } from "./ChatCoreZendeskConfig"; export { ChatCoreZendesk } from "./ChatCoreZendesk"; +export { ChatCoreZendeskSessionCredentials } from "./ChatCoreZendeskSessionCredentials";