diff --git a/ui/src/core_components/CoreChat.vue b/ui/src/core_components/CoreChat.vue
index b9e69648b..e635bbec1 100644
--- a/ui/src/core_components/CoreChat.vue
+++ b/ui/src/core_components/CoreChat.vue
@@ -15,11 +15,20 @@
}}
-
-
-
+
+
+
- {{ message.content }}
+
+ {{ message.text }}
+
+
+
+
{{ action.subheading }}
+
{{ action.name }}
+
{{ action.desc }}
+
+
= ref(null);
@@ -191,29 +209,56 @@ async function replaceMessage(messageKey: string, message: Message) {
async function handleMessageSent() {
await addMessage({
origin: "outgoing",
- content: outgoingMessage.value,
+ text: outgoingMessage.value,
date: new Date(),
});
- outgoingMessage.value = "";
const outgoingMessageKey = await addMessage({
origin: "incoming",
- content: "Loading...",
+ text: "Loading...",
isLoading: true,
});
const event = new CustomEvent("chat-message", {
detail: {
payload: outgoingMessage.value,
callback: ({ payload }) => {
- const content: string = payload.result?.result;
+ const contents = payload.result?.result;
replaceMessage(outgoingMessageKey, {
origin: "incoming",
- content,
+ text: contents?.text,
+ actions: contents?.actions,
date: new Date(),
});
},
},
});
rootEl.value.dispatchEvent(event);
+ outgoingMessage.value = "";
+}
+
+function handleActionClick(action: Message["actions"][number]) {
+ const {subheading, name, desc, data} = action;
+ const event = new CustomEvent("chat-action-click", {
+ detail: {
+ payload: {
+ subheading,
+ name,
+ desc,
+ data
+ }
+ // callback: ({ payload }) => {
+ // const text: string = payload.result?.result;
+ // replaceMessage(outgoingMessageKey, {
+ // origin: "incoming",
+ // text,
+ // actions: [
+ // {subheading: "WEBSITE", name: "Google", desc: "Leading search engine."},{subheading: "WEBSITE", name: "ChatGPT", desc: "AI chatbot, great for everyday use."}
+ // ],
+ // date: new Date(),
+ // });
+ // },
+ },
+ });
+ rootEl.value.dispatchEvent(event);
}