{"id":19689944,"url":"https://github.com/zoom/node.js-chatbot","last_synced_at":"2025-04-29T08:35:36.601Z","repository":{"id":49485113,"uuid":"205675379","full_name":"zoom/node.js-chatbot","owner":"zoom","description":"Zoom Node.js Chatbot Library","archived":true,"fork":false,"pushed_at":"2024-11-26T00:06:54.000Z","size":74,"stargazers_count":17,"open_issues_count":2,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T16:47:31.651Z","etag":null,"topics":["npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@zoomus/chatbot","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zoom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-01T12:49:03.000Z","updated_at":"2024-11-26T00:09:54.000Z","dependencies_parsed_at":"2022-08-24T21:31:48.564Z","dependency_job_id":null,"html_url":"https://github.com/zoom/node.js-chatbot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoom%2Fnode.js-chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoom%2Fnode.js-chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoom%2Fnode.js-chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoom%2Fnode.js-chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoom","download_url":"https://codeload.github.com/zoom/node.js-chatbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251465335,"owners_count":21593862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-package"],"created_at":"2024-11-11T19:03:46.170Z","updated_at":"2025-04-29T08:35:36.589Z","avatar_url":"https://github.com/zoom.png","language":"JavaScript","readme":"#### THIS PACKAGE IS DEPRECATED\n\nPlease see the latest official package [@zoom/rivet](https://www.npmjs.com/package/@zoom/rivet), thank you!\n\n---\n\n# Zoom Node.js Chatbot Library\n\nThe Zoom Node.js Chatbot Library wraps OAuth2, receiving slash commands and user actions, sending messages, and making requests to the Zoom API into easy to use functions you can import in your Node.js app.\n\n## Installation\n\nTo get started install the [@zoomus/chatbot](https://www.npmjs.com/package/@zoomus/chatbot) NPM package.\n\n```\n$ npm install @zoomus/chatbot --save\nconst {  oauth2, client, setting, log,request } = require('@zoomus/chatbot');\n```\n\n### 1. **Zoom OAuth2 Credentials Flow(prepare for request zoom openapi)**\n\nuse zoom oauth2 to request zoom openapi simple\n\nuse expires_date to auto check expired time,and auto use refresh_token to request access_token\n\nuse *let userInfo = await zoomApp.request({url:'/v2/users/me', method:'get'}); console.log(userInfo)* can get zoom account_id,jid and others information.(origin jwt.decode not useful again)\n\n\n**First install ZOOM bot app**\n```js\nconst { oauth2, client, setting, log } = require('@zoomus/chatbot');\nconst oauth2Client = oauth2( '{{ CLIENT_ID }}', '{{ CLIENT_SECRET }}', '{{ REDIRECT_URI }}' );\nlet chatbot = client( '{{ CLIENT_ID }}', '{{ VERIFICATION_TOKEN }}', '{{ BOT_JID }}' ).defaultAuth(oauth2Client.connect());\n\nlet middleZoomAuth = async (req, res, next) =\u003e {\n  let { code } = req.query;\n  try {\n    let connection = await oauth2Client.connectByCode(code);\n    let zoomApp = chatbot.create({ auth: connection }); //this is the first store tokens,zoomApp have already inject tokens by connection.you can use zoomApp to request zoom openapi\n    res.locals.zoomApp = zoomApp;\n    next();\n  } catch (error) {\n    console.log(error);\n    res.send(error);\n  }\n};\n\napp.get('/authorize', middleZoomAuth, async (req, res) =\u003e {\n  res.send('Thanks for installing!');\n  let { zoomApp } = res.locals;\n  let tokens = zoomApp.auth.getTokens();\n  // save tokens to db\n  // db.set('access_token',tokens.access_token);\n  // db.set('refresh_token',tokens.refresh_token);\n  // db.set('expires_date': moment().add( tokens.expires_in, 'seconds' ).format()');\n  // sendMessage to zoom\n  await zoomApp.sendMessage({...});\n  // request openapi of zoom\n  await zoomApp.request({url:'/v2/users/me', method:'get'});\n});\n```\n\n### 2. **SendMessage ZOOM IM Chat Message**\n\n**Get zoom channel/bot webhook message,and sendmessage to feedback channel/bot**\n\n```js\nconst {  oauth2, client, setting, log } = require('@zoomus/chatbot');\nconst oauth2Client = oauth2( '{{ CLIENT_ID }}', '{{ CLIENT_SECRET }}', '{{ REDIRECT_URI }}' );\nlet chatbot = client('{{ CLIENT_ID }}', '{{ VERIFICATION_TOKEN }}', '{{ BOT_JID }}').defaultAuth(oauth2Client.connect());\napp.post('/webhook',async function(req,res){\n  try{\n        let data = await chatbot.handle({ body, headers });\n        let { event, command?,type, payload } = data;\n        let { toJid, userJid, accountId } = payload;\n        let zoomApp = chatbot.create();\n        await zoomApp.sendMessage({\n            //is_visible_you: true|false,//only the userid user can see the message\n            //user_jid:userJid//which user can see this message\n            to_jid: toJid,\n            account_id:accountId,\n            content: {\n              head: {\n                 text: 'Hello World'\n               }\n            }\n        });\n  }\n  catch(e){\n    //\n  }\n}\n\n```\n\n\n\n\n### 3. **Get ZOOM IM chat message**\n\nhandle ZOOM IM chat webhook message,message have two sources, one is 'channel',another is 'bot'.And message have two types,one is 'slash',another is 'action'\n\npayload details please see zoom [zoom message-with-dropdown dropdown example](https://marketplace.zoom.us/docs/guides/chatbots/customizing-messages/message-with-dropdown)\n\nwe have slash event = 'bot_notification';\n\nwe have action event,'interactive_message_select','interactive_message_actions','interactive_message_editable','interactive_message_fields_editable'\n\n```js\nconst {  oauth2, client, setting, log } = require('@zoomus/chatbot');\nconst oauth2Client = oauth2( '{{ CLIENT_ID }}', '{{ CLIENT_SECRET }}', '{{ REDIRECT_URI }}' );\nlet chatbot = client('{{ CLIENT_ID }}', '{{ VERIFICATION_TOKEN }}', '{{ BOT_JID }}').defaultAuth(oauth2Client.connect());\napp.post('/webhook',async function(req,res){\n      try{\n        let data = await chatbot.handle({ body, headers });\n        //if this is slash from zoom IM,just like /help,command will be help,action will not have this option.\n        //type 'channel'|'bot', channel express this message from IM channel,bot express this message from the bot which you installed\n        let { event, command?,type, payload } = data;\n        //do the business logic \n      }\n      catch(e){\n        //\n      }\n});\n\n```\n\n\n### 4. **Request Zoom Open Api and Refreshing the Access Token(must do oauth2 first)**\n\nIf the access_token is expired, this function will request a new access_token, so you can update the tokens in your `zoomApp` instance and database.\n\n**auth get expired access_token from refresh_token**\n\n```js\nconst {  oauth2, client, setting, log } = require('@zoomus/chatbot');\nconst oauth2Client = oauth2( '{{ CLIENT_ID }}', '{{ CLIENT_SECRET }}', '{{ REDIRECT_URI }}' );\nlet chatbot = client('{{ CLIENT_ID }}', '{{ VERIFICATION_TOKEN }}', '{{ BOT_JID }}').defaultAuth(oauth2Client.connect());\n//see OAuth2 Credentials Flow for zoomApp\nlet zoomApp = chatbot.create();//zoomApp.auth is same with connection variable\nzoomApp.auth.setTokens({//get tokens from database and set into zoomApp\n        access_token: database.get('access_token'),\n        refresh_token: database.get('refresh_token'),\n        expires_date: database.get('expires_date')\n});\n// When request v2/users/me fail by accesstoken expired\n//Library will auto use refresh_token for request access_token. \n//After that, this function will be called,you can save new access_token in database. \n//Then will auto call request /v2/users/me again\nzoomApp.auth.callbackRefreshTokens((tokens,error) =\u003e {\n      if(error){\n        //try use refresh token to get access_token,but also fail,refresh token is invalid\n      }\n      else{\n        try {\n          await database.update({\n             id:'id',\n             access_token:tokens.access_token\n             refresh_token:tokens.refresh_token,\n             expires_date: moment().add( tokens.expires_in, 'seconds' ).format()\n          });\n      } catch (e) {\n          console.log(e);\n      }\n      }\n});\n\n\nawait zoomApp.request({url:'/v2/users/me', method:'get'});\n\n// await zoomApp.request({\n//         url: `/v2/users/${userId}/meetings`,\n//         method: 'post',\n//         headers: { 'content-type': 'application/json' },\n//         body: {\n//           topic: `New topic Meeting`,\n//           type: 2,\n//           settings: {\n//             host_video: true,\n//             participant_video: true,\n//             join_before_host: true,\n//             enforce_login: true,\n//             mute_upon_entry: true\n//           }\n//         }\n// });\n\n//await zoomApp.auth.requestTokensByRefresh(refreshToken); for refresh new access_token\n\n```\n\n**auth get new access_token from refresh_token by method**\n\n```js\ntry{\n  await zoomApp.request({url:'/v2/users/me', method:'get'});\n}\ncatch(e){\n  //tokens expired\n  let newTokens=await zoomApp.auth.requestTokensByRefresh(refreshToken);\n  //\n}\n```\n\n### 5. Log,auto log http\u0026\u0026error from library\n\nwe have two type log of info,one is {type:'http',{error,request,response}},another is {type:'error_notice',message:{error}} this error include http error/webhook data error.\nyou can use request method to auto log http information in custom logic,request({url:'',headers,body,bodyType,method});After request happen,will auto log information in the callback\n\n```js\nconst { oauth2, client, setting, log,request } = require('@zoomus/chatbot');\nlog(function(info) {\n  console.log(info);\n  let { type, message } = info;\n  if (type === 'http') {\n    let { request, error, response } = message; //response:{status,body},request:{body,url,headers,method}\n    //handle log info;\n  }\n});\n```\n\n\n### 6. **Common request method**\n\nRequest is the method which wrap [node-fetch](https://www.npmjs.com/package/node-fetch) and put form-data and form-parameters in simple object\n\n```js\nconst {request } = require('@zoomus/chatbot');\n//application/json type\nrequest({\n  url:string,\n  method:'post',\n  headers:{},\n  body:{a:1,b:2}\n});\n\n//form x-www-form-urlencoded\nrequest({\n  url:string,\n  method:'post',\n  headers:{},\n  body:{a:1,b:2},\n  bodyType:'formParameters'\n});\n\n//form-data \nrequest({\n  url:string,\n  method:'post',\n  headers:{},\n  body:{a:1,b:2},\n  bodyType:'formData'\n});\n\n//get query\nrequest({\n  url:string,\n  method:'get',\n  headers:{},\n  query:{\n    a:1,b:2\n  }\n});\n\n```\n\n### 7. **case sensitive in zoom IM message,default false**\n\n```js\nsetting.caseSensitive(false); //in zoom IM ,type help is same with Help\n```\n\n## Slash Commands and User Actions\n\n[Slash commands](https://marketplace.zoom.us/docs/guides/chatbots/sending-messages#receive) are what the user types in Zoom Chat to interact with your Chatbot.\n\n[User Actions](https://marketplace.zoom.us/docs/guides/chatbots/sending-messages#user-commands) are user interactions with the [Editable Text](https://marketplace.zoom.us/docs/guides/chatbots/customizing-messages/message-with-editable-text), [Form Field](https://marketplace.zoom.us/docs/guides/chatbots/customizing-messages/message-with-form-field), [Dropdown](https://marketplace.zoom.us/docs/guides/chatbots/customizing-messages/message-with-dropdown), or [Buttons](https://marketplace.zoom.us/docs/guides/chatbots/customizing-messages/message-with-buttons) message types in Zoom Chat.\n\n## Need help?\n\nIf you're looking for help, try [Developer Support](https://devsupport.zoom.us) or our [Developer Forum](https://devforum.zoom.us). Priority support is also available with [Premier Developer Support](https://zoom.us/docs/en-us/developer-support-plans.html) plans.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoom%2Fnode.js-chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoom%2Fnode.js-chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoom%2Fnode.js-chatbot/lists"}