Jericho / ZoomNet

.NET client library for the Zoom.us REST API v2
MIT License
69 stars 45 forks source link

(#20) Add Chatbot resource #312

Closed theit8514 closed 11 months ago

theit8514 commented 11 months ago

A bit of a complicated API. I added a simple text (or markdown) string message which can be used for quick messages. There is also the more complex message format syntax. It produces rich text messages like the below image. image

I also added some validation logic for the enable markdown flag, which Zoom provides the helpful "Invalid request body format." message.

theit8514 commented 11 months ago

This should fix the build error (adding a Models namespace to ZoomNet.UnitTests caused another reference to break).

Jericho commented 11 months ago

Man, you went all out on this one! Modeling two dozen (or so) classes, creating a new JSON converter and even adding a suite of integration tests. Bravo!

I created a Team Chat app for testing your code but I'm getting a {"code":7004,"message":"Not authorized.","result":false} response whenever I try to send a message. I was careful to figure out my app's robot JID and my own user's JID but I'm missing something else, evidently. I reviewed the scopes for my app and I don't see any privilege that I failed to grant to my app (nothing obvious anyway). I'm continuing my research...

Jericho commented 11 months ago

I tried sending a message to a channel rather than to a specific user but I'm getting the same "Not authorized" error.

Jericho commented 11 months ago

Out of frustration, I removed the app from my account and authorized it again and now it's working. 🤷‍♂️

Jericho commented 11 months ago

@theit8514 Is it just me or are there additional restrictions on which API a ChatBot is allowed to invoke? I am getting Account does not enabled REST API (dubious wording!) when invoking various API endpoints such as getting info about the current user, getting the list the list of available roles, getting metrics and reports, etc. To be clear: the methods you created such as sending, updating and deleting a chatbot message work fine, I am only getting this error message when invoking other API endpoints.

Assuming you had the same experience with the Account does not enabled REST API problem, I think we need to run the ChatBot API integration tests separate from the rest of the integration tests. I just raised an issue where I explain how I suggest achieving this goal.

theit8514 commented 11 months ago

Yes, I have also experienced the same response message from the Zoom API. From my experience here is how is is designed:

In order to use the integration tests I wrote I needed to add the client credentials flow to it. Sorry for not including that in the PR.

theit8514 commented 11 months ago

Also, as far as I can tell the imchat:write:admin scope is a lie. The description is Send a team chat message to a Zoom Team Chat user or channel on behalf of a Chatbot but none of the APIs on the Chatbot accept that scope (they require imchat:bot), nor was I able to send a message from a bot on a different client_id. Zoom did not comment on this when closing my ticket.

Jericho commented 11 months ago

Thanks for sharing your experience. This validates what I also experienced and confirms that we need to separate ChatBot integration tests from other API tests. I'll go ahead and accept your PR and work on #313