From d099b931d8ba2316bcf079f4e0bfbf1c7a63dc85 Mon Sep 17 00:00:00 2001 From: Chris Weaver <25087905+Weves@users.noreply.github.com> Date: Mon, 15 Jan 2024 15:33:55 -0800 Subject: [PATCH] Slack confirmation UI (#950) --- backend/danswer/danswerbot/slack/blocks.py | 2 +- .../admin/bot/SlackBotConfigCreationForm.tsx | 43 +++++++++++++++++++ web/src/app/admin/bot/lib.ts | 2 + web/src/components/admin/connectors/Field.tsx | 2 +- web/src/lib/types.ts | 1 + web/tailwind.config.js | 2 +- 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/backend/danswer/danswerbot/slack/blocks.py b/backend/danswer/danswerbot/slack/blocks.py index 762c8d6714bb..f9f2ffcdd358 100644 --- a/backend/danswer/danswerbot/slack/blocks.py +++ b/backend/danswer/danswerbot/slack/blocks.py @@ -294,7 +294,7 @@ def build_follow_up_resolved_blocks(tag_ids: list[str]) -> list[Block]: tag_str += " " text = ( tag_str - + "Someone has requested more help.\n:point_down:Please mark this resolved after answering!" + + "Someone has requested more help.\n\n:point_down:Please mark this resolved after answering!" ) text_block = SectionBlock(text=text) button_block = ActionsBlock( diff --git a/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx b/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx index 099452445df1..23c78cbb9801 100644 --- a/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx +++ b/web/src/app/admin/bot/SlackBotConfigCreationForm.tsx @@ -72,6 +72,11 @@ export const SlackBotCreationForm = ({ respond_team_member_list: existingSlackBotConfig?.channel_config ?.respond_team_member_list || ([] as string[]), + still_need_help_enabled: + existingSlackBotConfig?.channel_config?.follow_up_tags !== + undefined, + follow_up_tags: + existingSlackBotConfig?.channel_config?.follow_up_tags, document_sets: existingSlackBotConfig && existingSlackBotConfig.persona ? existingSlackBotConfig.persona.document_sets.map( @@ -90,6 +95,8 @@ export const SlackBotCreationForm = ({ questionmark_prefilter_enabled: Yup.boolean().required(), respond_tag_only: Yup.boolean().required(), respond_team_member_list: Yup.array().of(Yup.string()).required(), + still_need_help_enabled: Yup.boolean().required(), + follow_up_tags: Yup.array().of(Yup.string()), document_sets: Yup.array().of(Yup.number()), persona_id: Yup.number().nullable(), })} @@ -107,6 +114,13 @@ export const SlackBotCreationForm = ({ ), usePersona: usingPersonas, }; + if (!cleanedValues.still_need_help_enabled) { + cleanedValues.follow_up_tags = undefined; + } else { + if (!cleanedValues.follow_up_tags) { + cleanedValues.follow_up_tags = []; + } + } let response; if (isUpdate) { @@ -186,6 +200,35 @@ export const SlackBotCreationForm = ({ /> + Post Response Behavior + + + {values.still_need_help_enabled && ( + + The full email addresses of the Slack users we should + tag if the user clicks the "Still need help?" button. + For example, 'mark@acme.com'. +
+
+ If no emails are provided, we will not tag anyone and + will just react with a 🆘 emoji to the original message. + + } + /> + )} + + +
[Optional] Data Sources and Prompts diff --git a/web/src/app/admin/bot/lib.ts b/web/src/app/admin/bot/lib.ts index 6407383ac0c2..4888479f5c23 100644 --- a/web/src/app/admin/bot/lib.ts +++ b/web/src/app/admin/bot/lib.ts @@ -9,6 +9,7 @@ interface SlackBotConfigCreationRequest { questionmark_prefilter_enabled: boolean; respond_tag_only: boolean; respond_team_member_list: string[]; + follow_up_tags?: string[]; usePersona: boolean; } @@ -33,6 +34,7 @@ const buildRequestBodyFromCreationRequest = ( respond_tag_only: creationRequest.respond_tag_only, respond_team_member_list: creationRequest.respond_team_member_list, answer_filters: buildFiltersFromCreationRequest(creationRequest), + follow_up_tags: creationRequest.follow_up_tags?.filter((tag) => tag !== ""), ...(creationRequest.usePersona ? { persona_id: creationRequest.persona_id } : { document_sets: creationRequest.document_sets }), diff --git a/web/src/components/admin/connectors/Field.tsx b/web/src/components/admin/connectors/Field.tsx index 4e81d39fea8e..21ddec9fbe29 100644 --- a/web/src/components/admin/connectors/Field.tsx +++ b/web/src/components/admin/connectors/Field.tsx @@ -97,7 +97,7 @@ export function TextFormField({ interface BooleanFormFieldProps { name: string; label: string; - subtext?: string; + subtext?: string | JSX.Element; onChange?: (e: React.ChangeEvent) => void; } diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts index 4704f49dcb8a..aee8cb6d2f00 100644 --- a/web/src/lib/types.ts +++ b/web/src/lib/types.ts @@ -316,6 +316,7 @@ export interface ChannelConfig { respond_tag_only?: boolean; respond_team_member_list?: string[]; answer_filters?: AnswerFilterOption[]; + follow_up_tags?: string[]; } export interface SlackBotConfig { diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 1863f8967ffe..21d69d75560f 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -38,7 +38,7 @@ module.exports = { }, colors: { link: "#3b82f6", // blue-500 - subtle: "#9ca3af", // gray-400 + subtle: "#6b7280", // gray-500 default: "#4b5563", // gray-600 emphasis: "#374151", // gray-700 strong: "#111827", // gray-900