Send in a webhook message to a talk room

Hello!

I’ve been trying to send in a message to a nextcloud talk room, via webhooks, as a registered normal user, with no success so far. We use this feature extensively with Slack, but we would like to do this with Nextcloud instead.

The use case is to be able to send a message when something has happened as part of a CI workflow in Github or such.

In Slack, the process is super simple.

  1. Generate a token
  2. Send a message “Hello world” to a room which allows for it.

So far, I have found no information about how to achieve this with simple tools like curl, python etc. which to me seems like a pretty standard thing nowadays.

Can this be done?

We are on Nextcloud 30.0.8

Hey,

there are bots in Talk nowadays which can be used exactly for that, see: Bots and webhooks - Nextcloud Talk API documentation

If you still want to go the curl route, please see

So, for the curl path - I would need:

  • Username
  • Password (!)
  • Token (what token?)

Is this a correct assumption?

The link isn’t very clear on this and I can’t understand from it how to target a specific room. Its not in the url.

Here is what I got.

curl -u <username>:<password> 'https://nextcloud.example.com/ocs/v2.php/apps/spreed/api/v1/chat/<some-token>' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H "OCS-APIRequest: true" \
  --data-raw '{"message":"test123"}'

For the bot path, I don’t understand at all how this can be achieved, especially as a “normal” user. The documentation seems to indicate that only admins can enable bots. If that is the case, the development process will become unbearable as I would have to call admin every time I would need to test something?

Its really complicated with nextcloud, which is so easy in slack and used massively. A real bummer.

1 Like

Yes, bots need to be installed by admins (there can be bots that can be enabled by users, but first installation always needs to be done by admin).

  • Username → Yep
  • Password → Either the user password, or you can create an app token in the user settings (under Security). That should also work
  • Token → That’s the token of the conversation the message should be posted to. See the last part of the URL when you join the conversation in Web.
1 Like

This was indeed very helpful. It wasn’t clear from the documentation, but I managed to get a message through.

A followup on this thread is how I can create a low-access-level-key or similar with the sole access-rights to be able to send these webhooks to the specific room.

The security implications are a bit too wide using my own account as part of the authentication, whereas I would rather want a low-access-level credential to do this.

It would allow me to distribute that “app-key” without risking it being used to access other stuff in Nextcloud (since I would at present, distribute both username + api-key.)

There’s no such way for that. So if you don’t want to use your account, then

  • EIther use bots (needs Admin)
  • Use a separate “bot user” that is created just for that.
1 Like