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

reaction webhook for bots #14267

Open
rallisf1 opened this issue Jan 31, 2025 · 3 comments
Open

reaction webhook for bots #14267

rallisf1 opened this issue Jan 31, 2025 · 3 comments
Labels
1. to develop enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: bots 🤖 /commands in chat messages good first issue papercut

Comments

@rallisf1
Copy link

rallisf1 commented Jan 31, 2025

How to use GitHub

  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Feature request

Which Nextcloud Version are you currently using: (see administration page)
Nextcloud Hub 9 (30.0.5)

Is your feature request related to a problem? Please describe.
I am building a bot which should be able to respond to message reactions.

Describe the solution you'd like
Send a response similar to reaction_revoked, which works great. e.g.

{
  type: "Activity",
  actor: {
    type: "Person",
    id: "users/username",
    name: "Full Name",
  },
  object: {
    type: "Note",
    id: "468",
    name: "reaction",
    content: "{\"message\":\"{actor} added a reaction\",\"parameters\":{\"actor\":{\"type\":\"user\",\"id\":\"username\",\"name\":\"Full Name"},\"action\":\"\\ud83d\\udc4d"}}",
    mediaType: "text/markdown",
  },
  target: {
    type: "Collection",
    id: "7wnb37gn",
    name: "test",
  },
}

Describe alternatives you've considered
Poll the /reaction/{token}/{messageId} GET endpoint, but that creates unnecessary load.

Additional context
I tried adding the following to ReactionManager.php, but along with the webhook request to the bot it also writes the JSON message to the chat...

        $this->chatManager->addSystemMessage(
			$chat,
			$actorType,
			$actorId,
			json_encode(['message' => 'reaction', 'parameters' => ['message' => (int)$parentMessage->getId(), 'reaction' => $reaction]]),
			$this->timeFactory->getDateTime(),
			false,
			null,
			null,
			true
		);
@nickvergessen
Copy link
Member

This here is the message already and it's hidden by clients and the web interface:
https://github.com/nextcloud/spreed/blob/main/lib/Chat/ReactionManager.php#L66-L75

But yeah there is no bot invoke yet, as we didn't have a usecase for it and could triggere way too often from our experience.

Before we add this optionally, would you mind to explain your usecase a bit?

@rallisf1
Copy link
Author

rallisf1 commented Feb 1, 2025

I am integrating our ticketing system with talk. A bot posts all new tickets on a designated room and I'd like people to assign themselves to a ticket via the chat. Since there are no chat buttons, the closest thing is reactions (e.g. likes). I know I can set up some text command, but the less complicated it is the better it will work.

It just made no sense to me to have a bot invoke for reaction_revoke, but not for reaction.

If you are concerned about the load/traffic this would produce, perhaps it should be a separate bot feature (the same way webhook and response are), but disabled by default. Also make sure to move reaction_revoke to the same feature.

P.S. In my case both nextcloud and the ticketing system use the same and only oAuth2 provider, thus the account emails are identical and can be easily used to link users between the 2.

@nickvergessen
Copy link
Member

Yeah sounds good and a cool use case.

Feature flag sounds like the right plan I'm confused that revoked triggers it in first place, I will check what we can do about it

@nickvergessen nickvergessen added feature: api 🛠️ OCS API for conversations, chats and participants feature: bots 🤖 /commands in chat messages labels Feb 3, 2025
@nickvergessen nickvergessen added this to the 🌿 Next RC (31) milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: bots 🤖 /commands in chat messages good first issue papercut
Projects
None yet
Development

No branches or pull requests

2 participants