Slack confirmation UI (#950)

This commit is contained in:
Chris Weaver
2024-01-15 15:33:55 -08:00
committed by GitHub
parent 4cd9122ba5
commit d099b931d8
6 changed files with 49 additions and 3 deletions

View File

@@ -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(

View File

@@ -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 = ({
/>
<Divider />
<SectionHeader>Post Response Behavior</SectionHeader>
<BooleanFormField
name="still_need_help_enabled"
label="Should Danswer give a “Still need help?” button?"
subtext={`If specified, DanswerBot's response will include a button at the bottom
of the response that asks the user if they still need help.`}
/>
{values.still_need_help_enabled && (
<TextArrayField
name="follow_up_tags"
label="Users to Tag"
values={values}
subtext={
<div>
The full email addresses of the Slack users we should
tag if the user clicks the &quot;Still need help?&quot; button.
For example, &apos;mark@acme.com&apos;.
<br />
<br />
If no emails are provided, we will not tag anyone and
will just react with a 🆘 emoji to the original message.
</div>
}
/>
)}
<Divider />
<div>
<SectionHeader>
[Optional] Data Sources and Prompts

View File

@@ -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 }),

View File

@@ -97,7 +97,7 @@ export function TextFormField({
interface BooleanFormFieldProps {
name: string;
label: string;
subtext?: string;
subtext?: string | JSX.Element;
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

View File

@@ -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 {

View File

@@ -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