From 33dbcb5218814ca312bf2f1931e77d80fc7d2e7c Mon Sep 17 00:00:00 2001 From: Yash <67926590+Yash094@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:44:51 +0530 Subject: [PATCH 1/7] Updates --- src/bot.js | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/bot.js b/src/bot.js index c1abd87..c20abd0 100644 --- a/src/bot.js +++ b/src/bot.js @@ -30,10 +30,10 @@ const { version } = require("../package.json"); require("dotenv").config(); // discord bot tokens -const { - DISCORD_BOT_TOKEN, - DISCORD_SUPPORT_ROLE_ID, - CONTEXT_ID, +const { + DISCORD_BOT_TOKEN, + DISCORD_SUPPORT_ROLE_ID, + CONTEXT_ID, ASKAI_CHANNEL } = process.env; const token = DISCORD_BOT_TOKEN; @@ -107,7 +107,7 @@ client.on("messageCreate", async (message) => { }, onError: async (error) => { console.error(error); - + // send a message indicates unseccesful response from the AI await message.channel.messages.fetch(aiMessageLoading.id).then((msg) => msg.edit({ @@ -575,7 +575,9 @@ client.on("messageCreate", async (message) => { if (mentioned.roles.cache.hasAny(...roleIDs) && !member.roles.cache.hasAny(...roleIDs)) { message.reply({ embeds: [sendEmbedMessage(`We have moved to a community driven discord support model.\n\nYou can ask me all things thirdweb in the <#${ASKAI_CHANNEL}> channel. Use the command \`!askai\` or \`!ask\` followed by your question to get started.`)], - }); + }).then(msg => { + setTimeout(() => msg.delete(), 60000) + }) } } @@ -662,7 +664,7 @@ client.on("threadCreate", async (post) => { botId: CONTEXT_ID, query: question, onComplete: async (query) => { - + await post.messages.fetch(aiMessageLoading.id).then((msg) => msg.edit({ content: "", @@ -672,7 +674,7 @@ client.on("threadCreate", async (post) => { components: [FeedbackButtonComponent()], }) ); - + }, onError: (error) => { console.error(error); @@ -692,8 +694,17 @@ client.on("interactionCreate", async (interaction) => { const closeTag = post.availableTags.filter((item) => { return item.name == config.tag_name_close; }); + const resolutionTag = post.availableTags.filter((item) => { + return item.name == config.tag_name_resolve; + }); let initialTags = [closeTag[0].id, ...postTags]; let tags = [...new Set(initialTags)]; + let initialTagsResolution = [resolutionTag[0].id, ...postTags].filter( + (item) => { + return item != escalateTag[0].id; + } + ); + let tagsResolution = [...new Set(initialTagsResolution)]; const question = post.name; if (interaction.channel.ownerId != interaction.user.id) return; if (interaction.customId === "close") { @@ -733,6 +744,28 @@ client.on("interactionCreate", async (interaction) => { ephemeral: true, }); await interaction.message.edit({ components: [] }); + + // send embed message upon executing the resolve command + await interaction.channel.send({ + embeds: [sendEmbedMessage(`${config.reminder_resolve}`)], + content: `🔔 <@${message.channel.ownerId}>`, + }); + + // then archive / close it + await interaction.channel.edit({ + appliedTags: tagsResolution, + archived: false, + }); + sendData( + { + post_id: interaction.channel.id, + resolution_time: statusTime, + resolved_by: "Thirdweb Assistant", + }, + config.datasheet_resolve + ); + + } else if (interaction.customId === "not-helpful") { sendData( { @@ -742,11 +775,13 @@ client.on("interactionCreate", async (interaction) => { config.datasheet_feedback ); await interaction.reply({ - embeds: [sendEmbedMessage(`Thank you so much for your feedback!`)], + embeds: [sendEmbedMessage(`Thank you so much for your feedback, Please click the below "Submit a Ticket" button to create a support ticket!`)], content: `🔔 <@${interaction.channel.ownerId}>`, ephemeral: true, + components: [CloseButtonComponent()], }); await interaction.message.edit({ components: [] }); + } } }); From bf3d383fd51379389953a6adbe122995e35cbb8c Mon Sep 17 00:00:00 2001 From: Yash <67926590+Yash094@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:51:08 +0530 Subject: [PATCH 2/7] fix --- src/bot.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bot.js b/src/bot.js index c20abd0..d30759d 100644 --- a/src/bot.js +++ b/src/bot.js @@ -697,6 +697,9 @@ client.on("interactionCreate", async (interaction) => { const resolutionTag = post.availableTags.filter((item) => { return item.name == config.tag_name_resolve; }); + const escalateTag = post.availableTags.filter((item) => { + return item.name == config.tag_name_escalate; + }); let initialTags = [closeTag[0].id, ...postTags]; let tags = [...new Set(initialTags)]; let initialTagsResolution = [resolutionTag[0].id, ...postTags].filter( From 5ec8494440c4e934edc963cefae418721d5ba064 Mon Sep 17 00:00:00 2001 From: Waren Gonzaga Date: Thu, 14 Mar 2024 02:17:25 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=E2=9C=A8=20tweak:=20update=20assistance=20?= =?UTF-8?q?flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/bot.js | 10 +++++----- src/utils/core.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 79238c5..ad1c684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thirdweb-support-discord-bot", - "version": "2.0.11", + "version": "2.0.12", "description": "A self-hosted dedicated forum-based support Discord bot for the thirdweb community.", "main": "src/bot.ts", "author": "Waren Gonzaga", diff --git a/src/bot.js b/src/bot.js index d30759d..63c2b9b 100644 --- a/src/bot.js +++ b/src/bot.js @@ -577,7 +577,7 @@ client.on("messageCreate", async (message) => { embeds: [sendEmbedMessage(`We have moved to a community driven discord support model.\n\nYou can ask me all things thirdweb in the <#${ASKAI_CHANNEL}> channel. Use the command \`!askai\` or \`!ask\` followed by your question to get started.`)], }).then(msg => { setTimeout(() => msg.delete(), 60000) - }) + }) } } @@ -644,10 +644,10 @@ client.on("threadCreate", async (post) => { ); // send message upon creating of new ticket - post.send({ - embeds: [sendEmbedMessage(config.reminder_newpost)], - components: [CloseButtonComponent()], - }); + // post.send({ + // embeds: [sendEmbedMessage(config.reminder_newpost)], + // components: [CloseButtonComponent()], + // }); // log any new posts console.log( diff --git a/src/utils/core.js b/src/utils/core.js index f65a85c..0bada23 100644 --- a/src/utils/core.js +++ b/src/utils/core.js @@ -27,9 +27,9 @@ const sendEmbedMessage = (message) => { const CloseButtonComponent = () => { const close = new ButtonBuilder() .setCustomId('close') - .setLabel('Close') - .setEmoji('⚒️') - .setStyle(ButtonStyle.Danger); + .setLabel('Mark as Resolved') + .setEmoji('✅') + .setStyle(ButtonStyle.Success); const support = new ButtonBuilder() .setLabel('Submit a Ticket') From a738e3a8c62c6b0d7c0b72bebcfc1e3f8479dc58 Mon Sep 17 00:00:00 2001 From: Waren Gonzaga Date: Thu, 14 Mar 2024 07:24:46 +0000 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9C=A8=20tweak:=20remove=20close=20inter?= =?UTF-8?q?action=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/core.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/utils/core.js b/src/utils/core.js index 0bada23..5833199 100644 --- a/src/utils/core.js +++ b/src/utils/core.js @@ -24,13 +24,7 @@ const sendEmbedMessage = (message) => { * @param {string} message * @returns pre-defined embed style */ -const CloseButtonComponent = () => { - const close = new ButtonBuilder() - .setCustomId('close') - .setLabel('Mark as Resolved') - .setEmoji('✅') - .setStyle(ButtonStyle.Success); - +const CloseButtonComponent = () => { const support = new ButtonBuilder() .setLabel('Submit a Ticket') .setEmoji('💬') @@ -38,7 +32,7 @@ const CloseButtonComponent = () => { .setStyle(ButtonStyle.Link); const row = new ActionRowBuilder() - .addComponents(close, support); + .addComponents(support); return row } From ab5e5775e0480a4337c4cd346ecbb90d24912eed Mon Sep 17 00:00:00 2001 From: Yash <67926590+Yash094@users.noreply.github.com> Date: Thu, 14 Mar 2024 13:11:35 +0530 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=90=9B=20fix:=20assistance=20flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.js b/src/bot.js index 63c2b9b..293a4e7 100644 --- a/src/bot.js +++ b/src/bot.js @@ -751,7 +751,7 @@ client.on("interactionCreate", async (interaction) => { // send embed message upon executing the resolve command await interaction.channel.send({ embeds: [sendEmbedMessage(`${config.reminder_resolve}`)], - content: `🔔 <@${message.channel.ownerId}>`, + content: `🔔 <@${interaction.channel.ownerId}>`, }); // then archive / close it From bee9b8d422f1ec961aff0acc8b597819f93f774b Mon Sep 17 00:00:00 2001 From: Waren Gonzaga Date: Wed, 10 Apr 2024 08:02:19 +0000 Subject: [PATCH 6/7] =?UTF-8?q?=E2=98=95=20chore:=20update=20ask=20flow=20?= =?UTF-8?q?message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.js b/src/bot.js index 293a4e7..2687a9d 100644 --- a/src/bot.js +++ b/src/bot.js @@ -778,7 +778,7 @@ client.on("interactionCreate", async (interaction) => { config.datasheet_feedback ); await interaction.reply({ - embeds: [sendEmbedMessage(`Thank you so much for your feedback, Please click the below "Submit a Ticket" button to create a support ticket!`)], + embeds: [sendEmbedMessage(`Thank you for your valuable feedback, this will help us improve the responses of our AI assistant.\n\nIn the meantime, would you like to contact a human customer success agent? Just click the button below to submit a ticket.`)], content: `🔔 <@${interaction.channel.ownerId}>`, ephemeral: true, components: [CloseButtonComponent()], From 25d58f919bcc170a7d1a2e723dedec0efa5e663a Mon Sep 17 00:00:00 2001 From: Waren Gonzaga Date: Wed, 10 Apr 2024 08:17:20 +0000 Subject: [PATCH 7/7] =?UTF-8?q?=E2=98=95=20chore:=20update=20the=20message?= =?UTF-8?q?=20in=20ask=20flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bot.js b/src/bot.js index 2687a9d..e27a1d8 100644 --- a/src/bot.js +++ b/src/bot.js @@ -778,7 +778,7 @@ client.on("interactionCreate", async (interaction) => { config.datasheet_feedback ); await interaction.reply({ - embeds: [sendEmbedMessage(`Thank you for your valuable feedback, this will help us improve the responses of our AI assistant.\n\nIn the meantime, would you like to contact a human customer success agent? Just click the button below to submit a ticket.`)], + embeds: [sendEmbedMessage(`Thank you for your valuable feedback, this will help us improve the responses of our AI assistant.\n\nIn the meantime, would you like to contact a human customer success agent? Just click the link or the button below to submit a ticket.`)], content: `🔔 <@${interaction.channel.ownerId}>`, ephemeral: true, components: [CloseButtonComponent()],