Send chat messages via API

We are evaluating Zoom against Webex Teams & MS Teams. We need to create incoming webhooks to post messages into chat channels. We have done this in all 3 products using the provided webhook apps (e.g. ‘Incoming Webhook’ app in Zoom Marketplace). Unfortunately, with Zoom, the notifications on messages sent via webhooks do not include any message content, just ‘app - incoming webhook’. So, the notifications aren’t very useful, unlike Webex/MS Teams, which show a preview of the message in the notification.

So instead we tried to use the Zoom API to post chat messages. This is proving difficult. As far as we can tell there is no way to do this via scripts using JWT. The only way seems to be an OAuth user-level appliction, which means we can’t interact with the API using a script (as per JWT), but have to build a web application?!

It seems crazy that we can’t create simple chat messages with useful notifications in Zoom, using a script. If someone can help us, this would probably make our decision to go with Zoom, as we like everything else about it :slight_smile:

2 Likes

Hey @dan.atkinson, thanks for posting and using Zoom!

This is totally possible with via scripts with a Chatbot App.

Here are the steps:

  1. Simply Create a Chatbot App here.

  2. Enable Event Subscriptions on the Features page, and select which Webhooks you would like to subscribe to.

  3. Install your Chatbot App on the Local Test page (make sure to fill in the required info, you can use a generic redirect URL because that won’t be needed).

  4. Setup a way to accept the Webhooks, then format the JSON body from the webhook in a Chatbot message type of your choice

  5. Then get a Chatbot Token, and Send the Chatbot Message to a Zoom Channel or user.

Let me know if that helps! :slight_smile:

Thanks,
Tommy

Thanks Tommy - We’ll try that out tomorrow and I’ll report back.

1 Like

Sounds good! :slight_smile:

We are here to help!

-Tommy

Hi Tommy - We’ve been working on this today, I have a few questions:

  1. Simply Create a Chatbot App here.

OK we did that, no problems.

  1. Enable Event Subscriptions on the Features page, and select which Webhooks you would like to subscribe to.

We only need to post messages into chat channels, not subscribe to any events happening inside zoom, so I guess this is un-necessary.

  1. Install your Chatbot App on the Local Test page (make sure to fill in the required info, you can use a generic redirect URL because that won’t be needed).

OK this was done.

  1. Setup a way to accept the Webhooks, then[format the JSON body from the webhook in a Chatbot message type of your choice

Not sure what you mean by this, can you please clarify?

  1. Then get a Chatbot Token and Send the Chatbot Message to a Zoom Channel or user

We got the chatbot token OK, but can’t see where to get the required information for posting the message (e.g. robot_jid)

Hey @dan.atkinson,

Okay, yes, in that case this step is not necessary.

Since you don’t need to subscribe to any events, skip that step.

Robot Jid you find in your Chatbot’s settings on the “features” page.

To get the to_jid, you can either:

  1. Setup a User Level OAuth app and GET a channel.

or

  1. Use a Slash Command, which will send the to_jid as a post request to your server.

We are releasing an easier way to get the Channel / User Jids (to_jid) for Chatbots soon.

Thanks,
Tommy

Thanks Tommy.

So we have everything now except the to_jid - and to get get this we need an OAuth app or a Slash command, however, both need some server component on our side to receive the necessary responses?

What is the easier method for obtaining the to_jid and when will it be released?

Hey @dan.atkinson,

Do you have a specific channel or user you want to send this notifications to?

The easiest way to get a to_jid is to combine the userID of who you want the message to go to, with the string: @xmpp.zoom.us.

So if your UserID is abc the to_jid will be abc@xmpp.zoom.us

You can easily get a userID by JWT Decoding the access_token.

Thanks,
Tommy

Hey Tommy - We will want to send the scripted messages to specific channels (not users). What’s the easiest way to get a channel to_jid?

thanks,
Dan

Hey @dan.atkinson,

Here are 3 ways to get a channel to_jid:

  1. Use the Channel Jid helper Chatbot: https://github.com/tommygaessler/channels-chatbot

  2. Use a Slash Command, which will send the to_jid as a post request to your server.

  3. Setup a User Level OAuth app and GET a channel .

In addition to those 3 methods, we are coming out with a way for Chatbots to easily get a list of channels in March / April, so hang tight.

Thanks,
Tommy

@dan.atkinson were you able to get this going? I’m trying to do something very similar. Specifically trying to get my Zabbix monitoring server to send a message to a specific channel.

Hey @nmatese,

Are you seeing an error message? If so, please share more details and steps to reproduce the issue.

Thanks,
Tommy

@tommy

This is what I am using, note I’ve replaced my info with XXXX.

var params = JSON.parse(value),
req = new CurlHttpRequest(),
resp;

var data = “{\n “is_markdown_support”: true,\n “body”: {\n “text”: “<!all> test simple message”\n }\n}”;

req.AddHeader(‘Content-Type: application/json’);
req.AddHeader(‘Authorization: xxxxxxxx’);
resp = req.Post(‘https://inbots.zoom.us/incoming/hook/XXXXXXX?format=full’,
data
);
return resp;

The error I am getting is Internal Server Error.

@tommy any thoughts on how to resolve the internal server error?

Hi - No i didn’t get it working, we gave up for the time being, and all our webhooks are still running in Webex Teams, which is working great and very easy to configure.

I will revisit Zoom webhooks at some point - hopefully they can make it easier like Webex & MS Teams, although given the freeze on new features and security-focus, I guess this won’t be anytime soon.

Hey @nmatese,

Are you using the Incoming Webhook Bot? Or sending Chatbot messages?

Your request body is also missing the parent configuration object, it should be like this:

{
   "robot_jid": "v1m0yn1imztuogsxjje8fdew@xmpp.zoom.us",
   "to_jid": "kdykjnimt4kpd8kkdqt9fq@xmpp.zoom.us",
   "account_id": "gVcjZnWWRLWvv_GtyGuaxg",
   "content": {

   }
}

Thanks,
Tommy

@tommy I am using the incoming webhook. It works just fine if I send ?format=fields rather than full. How would I get the jid and ids for the webhook?

Hey @nmatese,

Since you are using the incoming webhook app you don’t need to set the jid and ids, ignore that haha. :slight_smile:

That is correct, follow the docs here for sending messages via the incoming webhook app.

Thanks,
Tommy

@tommy That brings me back to my original question where I listed my code. I get an internal server error. It works fine when I set format=fields but not when I set to format=full.

My whole goal here is to add a mention so that I will get push notifications on my phone when a message arrives in that channel. Currently the webhook sends the message to the channel but no notification when I send format=fields.

Thanks!

The problem we found with the ‘incoming webhook’ app is that the message notifications say ‘incoming webhook message’ or similar, rather than giving a preview of the message. This makes the notifications pretty useless, hence we can’t use incoming webhook app :frowning: