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
Allow outgoing webhook to add reaction when sending a response without additional calls to the REST API. #18117
base: main
Are you sure you want to change the base?
Conversation
Hello @zulip/server-bots members, this pull request was labeled with the "area: bots" label, so you may want to check it out! |
While working on the PR, I found that if the response message is not JSON, it will send an error message after the message that triggers it, but it doesn't notify the user. This might be inconsistent with our error handling logic for outgoing webhooks. Prove me wrong if it's intended this way. The following is the code responsible for this behavior. We might just want to raise a try:
response_json = json.loads(response.text)
except json.JSONDecodeError:
fail_with_message(event, "Invalid JSON in response")
return |
Good find; I think we ended up doing just that in b7b1ec0. |
A small comment on commit messages: You should only put |
Thank you for the feedback! |
I merged the first commit as 9c0ce19, after moving I pushed the second commit back here after a few small documentation/comment changes. It looks correct, but I'd like tests that actually verify the full set of parameters passed to |
It looks like that I have broken something with the rebase. |
3b9324f
to
703f1ea
Compare
Regarding the |
b7bd6a1
to
9e2e5de
Compare
I've rebased this due to a recent change. I'm not sure if a service bot is the only case when a user doesn't have a UserMessage row. It is possible that we can remove the check below? if (
user_profile.bot_type == UserProfile.EMBEDDED_BOT
or user_profile.bot_type == UserProfile.OUTGOING_WEBHOOK_BOT
): |
ca244e7
to
d391f04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @PIG208! This looks great, thanks for working on this! I just left a couple of minor comments.
As always, please feel free to reach out if you have any questions. Thanks! :)
0b95d3d
to
7dd3edc
Compare
0ad210e
to
594b862
Compare
@PIG208 I wonder why the build is failing here. Could you please investigate? |
I have rerun the tests several times and I think this might be a nondeterministic error? Will rerun it again. |
This commit allows service bots including embedded bots and outgoing webhook bots to access the private messages they sent or received in a group or a 1-to-1 chat. Related: zulip#13658
send_response_reaction is created for the sake of this feature, which is implemented in a way similar to `send_response_message`. Since this change, the outgoing webhooks will be able to respond to messages only with reactions, and sending a response message at the same time is also supported. Fixes: zulip#12811
Heads up @PIG208, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
4ec3636
to
88b200c
Compare
Fixes: #12811
Testing plan:
It has been tested both manually and with automated tests.
GIFs or screenshots:
This introduces a new format for response messages for outgoing webhooks:
It also works with
content
:Responding with two emoji reactions along with a message:
When the
emoji_name
field is missing in a specified emoji reaction:Updated documentation for the API:
Error messages;