Skip to content

Commit 5168d07

Browse files
committed
Add transition message
1 parent 865740b commit 5168d07

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/odie-client/src/hooks/use-create-zendesk-conversation.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getOdieZendeskConnectionErrorMessage } from '../constants';
55
import { useOdieAssistantContext } from '../context';
66
import { useManageSupportInteraction } from '../data';
77
import { useCurrentSupportInteraction } from '../data/use-current-support-interaction';
8+
import type { Message } from '../types';
89

910
export const useCreateZendeskConversation = () => {
1011
const {
@@ -140,9 +141,32 @@ export const useCreateZendeskConversation = () => {
140141
// We need to load the conversation to get typing events. Load simply means "focus on"..
141142
Smooch.loadConversation( conversationId );
142143

144+
const transitionToSupportMessage: Message = {
145+
content: null,
146+
role: 'bot',
147+
type: 'meta',
148+
internal_message_id: 'zendesk-chat-started',
149+
context: {
150+
site_id: selectedSiteId ?? null,
151+
flags: {
152+
hide_disclaimer_content: true,
153+
show_contact_support_msg: true,
154+
show_ai_avatar: false,
155+
},
156+
},
157+
metadata: {
158+
local_timestamp: Date.now(),
159+
},
160+
};
161+
143162
setChat( ( prevChat ) => ( {
144163
...prevChat,
145164
conversationId: conversationId,
165+
messages: prevChat.messages.some(
166+
( message ) => !! message?.context?.flags?.show_contact_support_msg
167+
)
168+
? prevChat.messages
169+
: [ ...prevChat.messages, transitionToSupportMessage ],
146170
provider: 'zendesk',
147171
status: 'loaded',
148172
} ) );

0 commit comments

Comments
 (0)