Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix postback #243

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/helpers/types/conversationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ IRichContent.prototype.quick_replies;
* @property {string} text - The message content.
* @property {string} editor - The message editor.
* @property {string} function - The function name.
* @property {string} [payload] - The payload.
* @property {RichContent} rich_content - Rich content.
* @property {string} post_action_disclaimer - The message disclaimer.
* @property {string} data - The message data.
Expand Down
11 changes: 9 additions & 2 deletions src/lib/scss/custom/common/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,23 @@ button:focus {
pre {
-ms-overflow-style: none !important;
white-space: pre-wrap;
margin-top: 0px;
margin-bottom: 0px;
}

pre::-webkit-scrollbar {
display: none !important;
}
p {

table {
margin-top: 1em !important;
margin-bottom: 1em !important;
}

p {
margin-top: 0 !important;
margin-bottom: 0 !important;
}

a {
color: white;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scss/custom/pages/_chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@
}

span p {
margin-top: 1em !important;
margin-bottom: 1em !important;
margin-top: 0px;
margin-bottom: 0px;
}

.chat-indication {
Expand Down
35 changes: 25 additions & 10 deletions src/routes/chat/[agentId]/[conversationId]/chat-box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
}

function handleSaveKnowledge() {
sendChatMessage("Save knowledge");
sendChatMessage("Save knowledge", { postback: { payload: '' } });
}

/**
Expand All @@ -544,9 +544,9 @@
const convId = conversationId || params.conversationId;

let postback = data?.postback;
if (!postback) {
postback = buildPostbackMessage(dialogs, data?.payload || msgText, data?.truncateMsgId);
}
// if (!postback) {
// postback = buildPostbackMessage(dialogs, data?.payload || msgText, data?.truncateMsgId);
// }

/** @type {import('$conversationTypes').MessageData?} */
let messageData = {
Expand Down Expand Up @@ -633,7 +633,7 @@
webSpeech.onSpeechToTextDetected = (transcript) => {
if (!!!_.trim(transcript) || isSendingMsg) return;

sendChatMessage(transcript).then(() => {
sendChatMessage(transcript, { postback: { payload: '' } }).then(() => {
microphoneIcon = "microphone-off";
}).catch(() => {
microphoneIcon = "microphone-off";
Expand Down Expand Up @@ -719,13 +719,14 @@
async function confirmSelectedOption(title, payload) {
if (isSendingMsg || isThinking) return;

await sendChatMessage(title, { payload: payload });
const postback = buildPostbackMessage(dialogs, payload || title, null);;
await sendChatMessage(title, { postback: postback });
}

async function sentTextMessage() {
const sentMsg = text;
text = '';
await sendChatMessage(sentMsg);
await sendChatMessage(sentMsg, { postback: { payload: '' } });
}

/**
Expand Down Expand Up @@ -900,8 +901,15 @@
cancelButtonText: 'No'
}).then(async (result) => {
if (result.value) {
let postback = null;
const found = dialogs.find(x => x.message_id === message?.message_id && USER_SENDERS.includes(x.sender?.role || ''));
const content = found?.payload;
if (content) {
postback = buildPostbackMessage(dialogs, content, message?.message_id);
}

deleteConversationMessage(params.conversationId, message?.message_id, true).then(resMessageId => {
sendChatMessage(message?.text, { inputMessageId: resMessageId });
sendChatMessage(message?.text, { postback: postback, inputMessageId: resMessageId });
});
}
});
Expand Down Expand Up @@ -964,8 +972,15 @@

async function confirmEditMsg() {
isOpenEditMsgModal = false;
let postback = null;
const found = dialogs.find(x => x.message_id === truncateMsgId && USER_SENDERS.includes(x.sender?.role || ''));
const content = found?.payload;
if (content) {
postback = buildPostbackMessage(dialogs, content, truncateMsgId);
}

deleteConversationMessage(params.conversationId, truncateMsgId, true).then(resMessageId => {
sendChatMessage(editText, { inputMessageId: resMessageId }).then(() => {
sendChatMessage(editText, { postback: postback, inputMessageId: resMessageId }).then(() => {
resetEditMsg();
}).catch(() => {
resetEditMsg();
Expand Down Expand Up @@ -1094,7 +1109,7 @@
isOpenBigMsgModal = !isOpenBigMsgModal;
const text = bigText;
bigText = '';
sendChatMessage(text);
sendChatMessage(text, { postback: { payload: '' } });
}

/**
Expand Down
Loading