Help with NextTalk Chat API

Can anyone help me with sending a new chat message using curl and API. I cannot figure out how to get the token…

  • Method: POST
  • Endpoint: /chat/{token}
1 Like

Well I can’t help you with a straight answer, but I have the same issue.
I assume your complete REST URL is something like:
https://example.org/ocs/v2.php/apps/spreed/api/v1/chat/{token}

I assume {token} is the room IT, which you can retrieve from the URL, when you select the chat room. In my case it is something like 59jpu5c9.

Though you still have to login. See here: https://docs.nextcloud.com/server/17/admin_manual//configuration_user/user_provisioning_api.html to get it all working.

Though, you can post as guest. That is what I want to do. I haven’t succeeded yet…

As an addition to @Bubbel s comment:
I managed to send a message as a logged-in user with curl like this.
As he said, the token is the identifier of the chat room (i found it in the URL of a chat window on my desktop). It’s used twice, once in the payload and once in the url to call.

-v makes output verbose, you’ll want to remove that
-u uses an App-Password you need to generate beforehand for the user account you want to use.

curl -d '{"token": "<nohu63se>", "message": "hi there @<username>}' -H "Content-Type: application/json" -H "Accept: application/json" -H "OCS-APIRequest: true" -v -u "<botusername>:<§%$verylongAppPasswordOfBotUser$%&>" https://<yourHost.YourUrl>/ocs/v2.php/apps/spreed/api/v1/chat/<nohu63se>

You’ll have to adapt everything between <>
There’s also an issue on github about the same: https://github.com/nextcloud/spreed/issues/1879

Yes, this absolutely works, except for the typo (missing a double quote, between the message text and the curly brackets).

Thank you for showing the way.
I’ve taken the liberty to put it all in a bash script, for easy usage, but I haven’t been able to post it here in a correct fashion, without it getting garbled (wrong quoting, missing backslashes, etc.

I will look into it an post when I know how.

Great ! it works … thanks all