Skip to content

Commit

Permalink
wip3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Sep 4, 2024
1 parent 76098bf commit dc66d13
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/chat-core-zendesk/src/CoreZendeskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ChatCoreZendeskImpl {
private eventListeners: { [T in keyof EventMap]?: EventCallback<T>[] } = {};
private conversationId: string | undefined;
private integrationId: string;
// eslint-disable-next-line @typescript-eslint/no-empty-function

constructor(config: ChatCoreZendeskConfig) {
if (window === undefined) {
throw new Error("This package can only be used in the browser.");
Expand Down
36 changes: 34 additions & 2 deletions packages/chat-core-zendesk/test-browser-esm-smooch/src/script.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
{
"searchId": "01918049-d466-4166-f801-87ee26824d92", "searchTerm": "What is this account", "results": { "appliedQueryFilters": [], "queryDurationMillis": 88, "results": [{ "rawData": { "id": "5498274745141875691", "type": "faq", "answerV2": { "json": { "root": { "type": "root", "direction": "ltr", "format": "", "indent": 0, "children": [{ "type": "paragraph", "direction": "ltr", "format": "", "indent": 0, "children": [{ "type": "text", "detail": 0, "format": 0, "mode": "normal", "style": "", "text": "This is team clippy's account! For testing!", "version": 1 }], "version": 1 }], "version": 1 } } }, "question": "What is this account", "name": "What is this account", "uid": "1007453985" }, "source": "KNOWLEDGE_MANAGER", "index": 1, "name": "What is this account", "id": "5498274745141875691", "highlightedFields": { "question": { "value": "What is this account", "matchedSubstrings": [{ "offset": 13, "length": 7 }] } }, "entityType": "faq" }], "resultsCount": 1, "source": "KNOWLEDGE_MANAGER", "verticalKey": "faqs" } }
import Smooch from "smooch";

window.init = async () => {
try {
await Smooch.init({
integrationId: "65f4a281e2bab7777482db6d",
embedded: true,
soundNotificationEnabled: false,
})

console.log('Smooch: package init')
const convo = await Smooch.createConversation({
metadata: {
"zen:ticket:tags": "yext-chat"
}
});
console.log('Smooch: convo', convo)
window.convoId = convo.id;
Smooch.on((message, data) => {
console.log('Smooch: message received', message, data)
})
} catch (error) {
console.log('Smooch: package init failed', error)
}

const div = document.createElement('div');
document.body.appendChild(div);
div.style.display = 'none';
Smooch.render(div);
}
window.sendMessage = async () => {
console.log('Frontend: sending message')
Smooch.sendMessage("Test!", window.convoId);
}

0 comments on commit dc66d13

Please sign in to comment.