This post is about how to create a Zoom bot with ASP.NET Core. Zoom is a collaboration solution by Zoom Communications Inc. In the Zoom developer documentation, they are implemented a Chat bot using Nodejs. In this post I am explaining how to implement a simple chatbot using ASP.NET Core.
So you need to Create a Zoom chat bot in Zoom marketplace - You can start it here - Zoom App Marketplace. Once you create the app, for development purposes you can use ngrok.exe as the redirection URLs. Here is the chatbot building documentation - Create a Chatbot App, I am just following the same, instead of Nodejs I am using ASP.NET Core and C#. For the demo purposes I am building an echo bot, which will echo what ever you’re typing.
So to get started, create an ASP.NET Core empty project. You need to put the following details in the appsettings.json file.
And use the following code, this is the minimal requirement for Zoom chat bot.
Now you can run ngrok, attach it your ASP.NET Core port like this - ./ngrok http 8080 -host-header="localhost:8080" I am running asp.net core projects on 8080 port. Now if you access your bot via Manage option in Zoom, you will get an option to Install the app.
Click on the install button, it will open a new browser tab and will show the permissions window which app is requesting. Click on the Authorize.
Once authorization is successful, it will launch the Zoom app with Bot in the chat window.
Next you can type some text in the chat window, which will send JSON payload to echo endpoint in your app, like the following.
In the payload object, we need to extract the cmd element. For the demo purposes I am not creating any model classes. Instead I am using Newtonsoft.Json package to parse the JSON.
Here is my echo endpoint code.
So we are able to receive the input from user. Next we need to write code to send the response back. For that we need to write some extra code which will generate a token and using the token send the message back to the user, like this.
The above code simple and straight forward. In the first section I am reading the payload I am receiving in the endpoint. Using JObject I am parsing it and populating the variables. In the next section, I am getting an access token to send IM to the user and in the third section I am creating the JSON object and sending it back to the user.
Here is the screenshot of the Bot running on my machine.
Now we have completed a minimal echo bot in Zoom with ASP.NET Core. You can enhance it by adding capabilities like attachment etc in Zoom. Also we need to implement the deauthorize endpoint, which is will be invoked by Zoom when user uninstalling the app.