jadolg/rocketchat_API

send richmessage

Closed this issue · 13 comments

I'm trying to port below program to use rocketchat_API

https://github.com/WideChat/python-richmessage-testbot/blob/master/richmessage_bot.py

Is there an API I can use to send a richmessage?

I'm not sure what you want to do there. What exactly is a "richmessage"? Can you send a "richmessage" using the sendMessage method of the API?
https://rocket.chat/docs/developer-guides/rest-api/chat/sendmessage/

I found this thread https://forums.rocket.chat/t/supporting-rich-chatbot-messages-menus/528/41 but I'm not really sure how to use it on this stage and it looks like it's not documented.

I want the Robot send a menu to the receiver, and the receiver can click the click inside the message and the selection of the receiver will be send back to the robot.

as far as I understood from that thread you should be able to do it on the attachments of the message, but I'm not sure how to because it's not documented on the API docs

here there is something related to sending attachments

https://rocket.chat/docs/developer-guides/rest-api/chat/postmessage/#attachments-detail

is there a sample or test available for sending attachment? thanks @jadolg

since attachments are not mandatory on the message I doubt we have tested for it. It should not be difficult to try though. The only complex field which might be problematic is fields and if you find problems with it we can always analyze them and try to solve them.

since attachments are not mandatory on the message I doubt we have tested for it. It should not be difficult to try though. The only complex field which might be problematic is fields and if you find problems with it we can always analyze them and try to solve them.

OK. I will try it and let you know the result. :-)

@jadolg I've finished the test.

Please find below a screenshoot:
image

And some code snipnet below:

att = [{
      "title": "text button with msg in chat window",
      "actions": [
        {
          "type": "button",
          "text": "Say hello in chat window?",
          "msg": "hello in chat window",
          "msg_in_chat_window": True
        }
      ]
    }]
pprint(rocket.chat_post_message("Title", channel='robotest', alias='Robot-Kai', attachments=att).json())
pprint(rocket.chat_post_message('', channel='robotest', alias='Robot-Kai', attachments=att).json())
pprint(rocket.chat_post_message(None, channel='robotest', alias='Robot-Kai', attachments=att).json())

There is one issue found, I was not able to send a richmessage without the text field. I modified the SDK to handle this scenario. One pull request was issued for your evaluation.

#80

that's fantastic!
could you add this to the wiki so it is recorded how to do it?
as soon as your pull request (#80) passes the tests I'll merge it.

Sorry, off the topic, I was not able to find an Edit button here https://github.com/jadolg/rocketchat_API/wiki

Do I need to clone/modify and commit?

My bad, I had it set incorrectly

My bad, I had it set incorrectly

https://github.com/jadolg/rocketchat_API/wiki/Send-richmessage

initial version added.
let's improve it step by step.

fantastic!
nice work!

I'm going to close this issue now as it's already documented how to send richmessages on the wiki.