diff --git a/package-lock.json b/package-lock.json index 6e25545..3436274 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9560,7 +9560,7 @@ }, "packages/chat-core-zendesk": { "name": "@yext/chat-core-zendesk", - "version": "0.1.0", + "version": "0.1.1", "license": "BSD-3-Clause", "dependencies": { "smooch": "5.6.0" diff --git a/packages/chat-core-zendesk/package.json b/packages/chat-core-zendesk/package.json index a0c1987..dab2d09 100644 --- a/packages/chat-core-zendesk/package.json +++ b/packages/chat-core-zendesk/package.json @@ -1,6 +1,6 @@ { "name": "@yext/chat-core-zendesk", - "version": "0.1.0", + "version": "0.1.1", "description": "Typescript Networking Library for the Yext Chat API Integration with Zendesk", "main": "./dist/commonjs/index.js", "module": "./dist/esm/index.mjs", diff --git a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts index 0bf3c9a..c1cce23 100644 --- a/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts +++ b/packages/chat-core-zendesk/src/infra/ChatCoreZendeskImpl.ts @@ -88,13 +88,23 @@ export class ChatCoreZendeskImpl { * with the conversation summary as the initial message. */ private async setupSession(messageRsp: MessageResponse) { - const convo: Conversation = await Smooch.createConversation({ + let convo: Conversation = await Smooch.createConversation({ metadata: { "zen:ticket:tags": "yext-chat", // this indicates to the internal zendesk bot webhook that the conversation is from the Chat SDK [MetadataChatSDKKey]: true, }, }); + + // On first conversation creation of a new user, the id is TEMPORARY_CONVERSATION. + // We need to re-fetch the current conversation to get the actual id. + if (convo.id === 'TEMPORARY_CONVERSATION') { + const currentConversation = Smooch.getDisplayedConversation(); + if (!currentConversation) { + throw new Error("No conversation found"); + } + convo = currentConversation; + } this.conversationId = convo.id; Smooch.loadConversation(convo.id); Smooch.sendMessage( diff --git a/test-sites/test-browser-esm/package-lock.json b/test-sites/test-browser-esm/package-lock.json index 97c86fe..0ebf5c4 100644 --- a/test-sites/test-browser-esm/package-lock.json +++ b/test-sites/test-browser-esm/package-lock.json @@ -88,7 +88,7 @@ "@microsoft/api-extractor": "^7.34.8", "@types/jest": "^29.5.1", "@types/node-fetch": "^2.6.4", - "@yext/chat-core": "^0.8.2", + "@yext/chat-core": "^0.9.1", "@yext/eslint-config": "^1.0.0", "babel-jest": "^29.5.0", "dotenv": "^16.4.5", @@ -102,7 +102,7 @@ "typescript": "^5.0.4" }, "peerDependencies": { - "@yext/chat-core": "^0.8.2" + "@yext/chat-core": "^0.9.1" } }, "../../packages/chat-core-zendesk": { @@ -119,7 +119,7 @@ "@microsoft/api-extractor": "^7.34.8", "@types/jest": "^29.5.1", "@types/smooch": "^5.3.7", - "@yext/chat-core": "^0.8.2", + "@yext/chat-core": "^0.9.1", "@yext/eslint-config": "^1.0.0", "babel-jest": "^29.5.0", "eslint": "^8.39.0", @@ -132,7 +132,7 @@ "typescript": "^5.0.4" }, "peerDependencies": { - "@yext/chat-core": "^0.8.2" + "@yext/chat-core": "^0.9.1" } }, "node_modules/@jridgewell/sourcemap-codec": {