Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@zoomus/chatbot
Advanced tools
The Zoom Node.js Chatbot Library wraps the OAuth2, sending messages,request zoom openapi, and receiving commands/actions functionality into easy to use functions you can import in your Node.js app.
To get started install the @zoomus/chatbot
$ npm install @zoomus/chatbot --save
oauth2
and client
functions.
const { oauth2, client } = require('@zoomus/chatbot');
const oauth2Client = oauth2('{{ CLIENT_ID }}', '{{ CLIENT_SECRET }}','{{REDIRECT_URI}}');
//SLASH_COMMAND
let chatbot = client('{{ CLIENT_ID }}', '{{ VERIFICATION_TOKEN }}', '{{ BOT_JID }}')
.commands([{ command: '{{ SLASH_COMMAND }}', hint: '<command parameter>', description: 'This is what my chatbot does' }])
.configurate({ help: true, errorHelp: false })
.defaultAuth(oauth2Client.connect());
let middleZoomWebhook=async function(req,res,next){
let {body,headers}=req;
try{
let wehookData = await chatbot.handle({ body, headers });
//create a app instance
let zoomApp = chatbot.create({ auth: oauth2Client.connect()});
res.locals.zoomApp = zoomApp;
res.locals.wehookData = wehookData;
next();
}
catch(e){
//handle error
}
};
app.post('/webhook',
middleZoomWebhook,
async function(req,res){
let {zoomApp, wehookData}=res.locals;
let { payload,data,type,command,message } = wehookData;
let { toJid: to_jid,command,data, userId, accountId: account_id, channelName,name } = payload;
try{
await zoomApp.sendMessage({
to_jid,account_id,content:{body:{type:'message',text:'example body'},header:{text:'example header'}}
});
}
catch(e){
//handle error
}
res.send('');
});
After you install and authorize your app, you will be taken to your redirect url. Add this code to handle the redirect.
Make sure your Redirect URL in your Zoom App Dashboard has the
/authorize
path so it matches with this rout\
let middleZoomAuth=async function(req,res,next){
let {code}=req.query;
try{
let connection=await oauth2Client.connectByCode(code);
let zoomApp=chatbot.create({auth:connection});
res.locals.zoomApp=zoomApp;
next();
}
catch(e){
// error handle
}
};
app.post('/auth',
middleZoomAuth,
async function(req,res){
let { zoomApp } = res.locals;
let tokens = zoomApp.auth.getTokens();
try{
//save tokens to db
//request openapi meetings
let meetings=await zoomApp.request({
url:'/v2/users/userid/meetings',
method:'post',
body:{
topic:'my meeting',
type:2,
settings:{
host_video: true,
participant_video: true
}
}
});
//handle other logic
}
catch(e){
//error handle
}
});
To capture requests sent to our Bot endpoint URL, setup an express route that matches the path on our Bot endpoint URL.
Commands are slash commands a user types in Zoom Chat to interact with your Chatbot.
Actions are user interaction events with the Editable Text, Form Field, Dropdown, or Buttons message types in Zoom Chat.
Payload api please see https://marketplace.zoom.us/docs/guides/chatbots/sending-messages
//notification webhookData
Interface WehookData{
type:string;//value:one||group, group which said message is from Zoom IM Channel,one which said message is from your app chat
payload:Payload;
message:string;//origin content from ZOOM IM ,just like 'config project 2019-08-08'
data:Array<string>;//just like ['project','2019-08-08']
command:string;//command name,just like config
}
//action webhookData
Interface WebhookData{
type:string;//value:one||group, group which said message is from Zoom IM Channel,one which said message is from your app chat
payload:Payload;
}
let zoomApp = chatbot.create({ auth: oauth2Client.connect()});
let backMessage=await zoomApp.sendMessage({
to_jid:String,
account_id:String,
content:{
body:Object,
header:Object
}
});
let zoomApp=chatbot.create({auth:connection});
//meeting openapi example
let meetings=await zoomApp.request({
url:'/v2/users/userid/meetings',
method:'post',
body:{
topic:'my meeting',
type:2,
settings:{
host_video: true,
participant_video: true
}
}
});
zoomApp.auth.callbackRefreshTokens(function(tokens){
//this tokens is the new access_token info which request by refresh token
});
zoomApp.auth.setTokens({
access_token,
refresh_token,
expires_in
});
let {setting}=require('@zoomus/chatbot');
//this will try to sendMessage again if get last request error(code 7010)
setting.retry({
// request:{}
sendMessage:{
no:3,
timeout(no,lg){return Math.random() * (10000 - 5000) + 5000;},
condition(backMsg,ind){//backMsg is https response message,ind is the retry no
if(typeof backMsg==='object'&&backMsg.code&&backMsg.code.toString()==='7010'){
return true;
}
}
});
setting.debug(true);
DEBUG=http node index.js //now only support http debug
The first place to look for help is on our Developer Forum, where Zoom Marketplace Developers can ask questions for public answers.
If you can’t find the answer in the Developer Forum or your request requires sensitive information to be relayed, please email us at developersupport@zoom.us.
FAQs
Zoom Node.js Chatbot Library
The npm package @zoomus/chatbot receives a total of 4 weekly downloads. As such, @zoomus/chatbot popularity was classified as not popular.
We found that @zoomus/chatbot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.