Skip to content

Commit 0ea5adf

Browse files
feat: support thread id
1 parent 23ae330 commit 0ea5adf

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

components/chat-sdk.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ interface ChatbotProps {
6767
export function Chat({ chatbot, defaultMessage, className, withExitX = false, clientSidePrompt, ...props }: ChatbotProps) {
6868

6969
const [count, setMessagesCount] = useState(0);
70+
const [threadId, setThreadId] = useState('');
7071

7172
function handleMessagesChange(messages: Message[]) {
7273
setMessagesCount(messages.length);
7374
}
7475

76+
function handleThreadIdChange(threadId: string | undefined) {
77+
setThreadId(threadId || '');
78+
}
79+
7580
console.log(chatbot);
7681

7782
return (
@@ -83,8 +88,9 @@ export function Chat({ chatbot, defaultMessage, className, withExitX = false, cl
8388
chatbotLogoURL: chatbot.chatbotLogoURL || '',
8489
}} path={`/api/chatbots/${chatbot.id}/chat`} withExitX={withExitX} clientSidePrompt={clientSidePrompt} defaultMessage={defaultMessage} {...props}
8590
onMessagesChange={handleMessagesChange}
91+
onThreadIdChange={handleThreadIdChange}
8692
extensions={[
87-
chatbot.inquiryEnabled && count > chatbot.inquiryDisplayLinkAfterXMessage && <SupportInquiry key="inquiry" chatbot={chatbot} threadId={chatbot.id} />
93+
chatbot.inquiryEnabled && count > chatbot.inquiryDisplayLinkAfterXMessage && <SupportInquiry key="inquiry" chatbot={chatbot} threadId={threadId} />
8894
]}
8995
/>
9096
)

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)