question

Upvotes
Accepted
3 0 1 2

Not authorized for API access when getting invites

Hi there,

My bot is able to login, retrieve the WS stream, establish a WS connection and receive messages posted on the web eikonmessenger. It also receive chat room invitations such as "{"event":"chatroomInvite","invite":{"chatroomId":"xxxx","chatroomType":"chatroom","from":{"email":"xxxx","company":"xxxx"},"status":"pending"}}".

Questions:

  1. Does the bot need to accept those invitations to start receiving messages? Or does it join automatically the chatrooms when invited? I noticed this endpoint in your postman example: "/messenger/beta1/chatrooms/invites" but there is no mention of it in the documentation.
  2. When calling "messenger/beta1/chatrooms/invites" from postman or java, an error is received indicating that the bot the is unauthorized despite the login and WS stream requests being successfull. Would you know what is the problem? Happy to provide the bot id in private if needed.

Thank you for your help

#technology#productmessenger-bot-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @kevin.deville

Please be informed that the question has been moved to Messenger Bot forum.

Hi @kevin.deville ,

Could you please let us know that this has been solved off the forum yet?

Thanks,
AHS

Hi AHS, changing the name of the bot to "bot_agent" helped fix the "unauthorized" error.
Still getting "Too many requests" error despite waiting 5 sec between each join request

Hello @kevin.deville

I am sorry that the "Too many requests" persist.

Can you try to wait longer between each join request?

Please let me know how many rooms the bot tries to join.

@kevin.deville

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

yes all good thank you
Upvotes
Accepted
24.6k 54 17 14

Hello @kevin.deville

Based on the bot team investigation, the bot username should contain "bot_agent" special prefix, but your bot email has a different pattern.

Please contact dino.diviacchi@lseg.com to verify your bot account.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.6k 54 17 14

Hello @kevin.deville

Thank you for contacting us. Please see my answer below:

Question 1: Does the bot need to accept those invitations to start receiving messages? Or does it join automatically?

Answer: I am checking with the Messenger Bot team and I will get back to you.

Question 2: When calling "messenger/beta1/chatrooms/invites" from postman or java, an error is received indicating that the bot is unauthorized despite the login and WS stream request being successful.

Answer: Do you mean the Messenger Bot REST API https://api.refinitiv.com/messenger/beta1/chatrooms/{ {chatroomId}}/invite endpoint? If so, you need to send the access token (STS Token) with the HTTP request header to confirm authentication grants as follows:

POST /messenger/beta1/chatrooms/{
  {chatroomId}}/invite HTTP/1.1
Host: api.refinitiv.com
Accept: application/json
Authorization: Bearer <Access Token>
Content-Type: application/json
Content-Length: 63

{
    "emails": ["user@domain.com"]
}

Note: Please be noticed "a space" between "Bearer" and <Access Token>.

Based on your "despite the login and WS stream requests being successful" message, it means you already get the Access Token and connect to the WebSocket Server somewhere else. Am I correct?

If so, you need to re-authentication with RDP API Auth Service (https://api.refinitiv.com/auth/oauth2/v1/token) on Postman or Java to get the access token first. Otherwise, you need to copy the access token and set it to the Postman or the Java app.



icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

any luck please? thank you
Hi @kevin.deville

Sorry for the late reply, I am still waiting information from the Messenger Bot API team.

Upvotes
3 0 1 2

Thanks wasin for the quick answer

No I mean:

https://{
  {URL}}/messenger/beta1/chatrooms/invites

But maybe this is only for BLC and not managed chats. Will wait for your answer on question 1 then.

Note that this is the only endpoint I could find in your postman example while trying to find a way to accept the invites. The shown status of the invites I receive is pending and I don't receive messages. I couldn't find any information in the documentation.

I'm able to get the STS token and pass it in the header using Bearer yes. Similarly to the Get WS Stream request basically.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.6k 54 17 14

Hello @kevin.deville

Sorry for the late reply. The Messenger Bot team confirms the bot can accept the invitation and join that chatroom using a Join chatroom HTTP command as follows:

curl --location --request POST 'https://api.refinitiv.com/messenger/beta1/chatrooms/<chatroomId>/join' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data ''

The success response body is like this:

{
    "member": {
        "email": <bot email>,
        "affiliation": "admin",
        "role": "moderator"
    }
}

I hope this helps.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks Wasin. So, if the invitations need to be explicitly accepted, how can the bot retrieve the list of pending ones and associated chat room ids? As mentioned, I tried different end points but always getting unauthorized error (e.g. https://api.refinitiv.com/messenger/beta1/managed_chatrooms, https://api.refinitiv.com/messenger/beta1/chatrooms, /messenger/beta1/chatrooms/invites).

Thank you!

Upvotes
24.6k 54 17 14

Hello @kevin.deville

According to the Messenger Bot team, Bot could get all available invitations from others through the following REST API call:

curl --location --request GET 'https://api.refinitiv.com/messenger/beta1/chatrooms/invites' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Access Token>'

Could you please clarify the issue?

Do you mean you got an unauthorized error from the API call above?

Or

You can get the list of invite rooms successfully, but when you call HTTP Post <chatroomId>/join, you got an unauthorized error.

It would be nice if you can share the full response/error message from the API call

By the way, please confirm if you are using the managed or bilateral chatroom.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 0 1 2

Sure, let me recap:

Using the bot API, I am able to login, retrieve the WS stream, establish a WS connection and receive messages posted on the web eikonmessenger (i.e. https://collab.platform.refinitiv.com/eikonmessenger).
In the logs, I noticed the bot received chat room invitations such as ""event":"chatroomInvite","invite":{"chatroomId":"xxxx","chatroomType":"chatroom","from":{"email":"xxxx","company":"xxxx"},"status":"pending"}}".

I am therefore trying to find a way for the bot to join these chat rooms as the bot does not seem to accept them automatically and receive messages. The received chatroomInvite mesages do not indicate the type of room (managed or bilateral) and are now x days old.

I therefore need a way to retrieve the list of room ids for which invitations have been sent and are pending.

I did try the endpoint you are mentioning above as mentioned in my initial post

/messenger/beta1/chatrooms/invites

but was always getting the same error indicating that the bot the is unauthorized.

I confirm I am using the same curl script as above. I also tried via Postman using the provided example.

Could this be a scope issue for the bot account I am using?

Note that today the bot seems to have exceeded the API limit as I receive a "Too many requests" error. However, there is no information regarding the API limits in the bot API documentation so I have no idea how long I will have to wait for the bot to be active again.

Thank you for your help

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.6k 54 17 14

Hello @kevin.deville

Thank you very much for the detailed description. I am understanding the scenario now.

Getting a Chat room invites

I am contacting the Messenger Bot team. I will get back to you as soon as I receive any information from them.

API Limit

The Messenger Bot API REST interface has the following usage limits:

  • /chatrooms/{chatroomId}/join endpoint: 2 requests per second
  • Other endpoints (example: /chatrooms/{ chatroomId }/post, etc.): 1 request per second

The usage limit is for protecting the backend from being overloaded.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.6k 54 17 14

Hello @kevin.deville

The Messenger Bot team is checking the issue. In the meantime, please confirm the following information:

  1. The bot application sends a valid and non-expired sts token with the /chatrooms/invites API call
  2. Does the sts token you send in (#1) the same as the one bot login to the WebSocket?

So, can I assume that your steps are as follows?

  1. bot login to RDP /auth/oauth2/v1/token
  2. bot got sts token
  3. bot establishes a WebSocket connection to the Messenger Bot API WebSocket server
  4. Once a WebSocket connection is established, sends a connection request message (a ‘connect’ command) with the sts token (from #2) information to the WebSocket server
  5. bot call /chatrooms/invites API with the same (#2, #4) sts token
  6. bot got authen error response
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.