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

Ephemeral slack messages as responses to user questions #4142

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

joachim-danswer
Copy link
Contributor

Description

We want to enable our customers to configure an Onyx bot for a channel such that the bot is able to respond as an ephemeral message to the user who is asking the question. That provides us with the ability to leverage documents for the search that a user has private access to, not just documents that are public to everyone.

See details in the current design doc.

Ticket: https://linear.app/danswer/issue/DAN-1489/enable-ephemeral-replies-by-answer-bot-in-group-channels

How Has This Been Tested?

Locally:

  • set up new bot in test mode
  • configured two channels, one with the new is_ephemeral parameter=True, the other one set to false
  • for each, I sent a request to the bot from
    • the channel
    • a thread
  • in the channel with the ephemeral setting I check for both question sources (channel vs thread) the button clicks 'Shae with Channel', and 'Keep for Yourself.

Key test cases:

  • are the documents properly transferred
  • are the new locations correct

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Feb 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 3, 2025 3:57pm

@@ -161,27 +161,33 @@ class SeedPresaveDocument(BaseModel):
url="https://docs.onyx.app/more/use_cases/overview",
title=overview_title,
content=overview,
title_embedding=model.encode(f"search_document: {overview_title}"),
content_embedding=model.encode(f"search_document: {overview_title}\n{overview}"),
title_embedding=list(model.encode(f"search_document: {overview_title}")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these just typing changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For anopther PR I need to upgrade HF version, which apparently changes the type here, so 'list' was needed to make it work with my local version.

As that is another PR though, I will remove.

@@ -72,6 +72,11 @@ def make_slack_api_rate_limited(
@wraps(call)
def rate_limited_call(**kwargs: Any) -> SlackResponse:
last_exception = None

if "thread_ts" in kwargs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment as to why we're doing this? Also, are we sure this should be the desired logic for all slack calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was actually not necessary. Sending thread_ts as None is equivalent to removing that key.

Code snippet removed.

channel_conf: ChannelConfig | None = None,
feedback_reminder_id: str | None = None,
) -> Block:
if not chat_message_id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need to have these checks here—we can just rely on mypy / typing to handle this.

In other words, we could just have the typing as:

chat_message_id: int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Done.

if not chat_message_id:
raise ValueError("Chat message id is required to change the ephemeral message")

if message_info is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as the ^ for these 2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def build_publish_ephemeral_message_id(
original_question_ts: str | None = None,
) -> str:
if original_question_ts is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if action_id == SHOW_EVERYONE_ACTION_ID:
# Convert to non-ephemeral message in thread
try:
webhook.send(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this one specifically do? Would be nice to add a comment here

# The additional data required that was added to buttons.
# Specifically, this contains the message_info, channel_conf information
# and some additional attributes.
value_dict = json.loads(req.payload["actions"][0]["value"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reference / a small enhancement: would prefer to get things into the "typed world" as soon as possible. In this case, that would mean converting this into a pydantic model / a typed dict.

todos:
  - search using private docs
  - review
- Updated frontend descriptions
- removal of 'I need help'-type options
- proper handling of response group
- no response group + ephemeral
- always check ACL
- if not ephemeral, only use public docs (user = None)
- changed warning in slack bot
- shortened 'share with everyone' button
@joachim-danswer joachim-danswer force-pushed the ephemeral-Slack-messages branch from 3ce1225 to a14060b Compare March 3, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants