const createRoom = { method: 'POST', url: xmpp_api_url + '/create_room_with_opts', headers: { 'Content-Type': 'application/json', Authorization: xmpp_auth }, body: { name: xmpp_muc_name, service: xmpp_muc_server, host: bot_hostname, options: { allow_change_subj: 'false', allow_private_messages: 'false', allow_private_messages_from_visitors: 'false', allow_visitor_nickchange: 'false', allow_visitor_status: 'false', lang: 'en', mam: 'true', members_only: 'true', persistent: 'false', public: 'false', public_list: 'false', title: 'Secure channel generated by https://vxmppb.tk', allow_subscription: 'true' } }, json: true }; // send request to create room request(createRoom, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); // wait 2 seconds until room has been created (http issues) setTimeout(() => { // loop through friends, authorize users, and send invites for (const key in config.friends) { // send xmpp message to friends alerting of new room xmpp.send(key, "Meeting started"); // authorize users const addMember = { method: 'POST', url: xmpp_api_url + 'set_room_affiliation', headers: { 'Content-Type': 'application/json', Authorization: xmpp_auth }, body: { name: xmpp_muc_name, service: xmpp_muc_server, jid: key, affiliation: 'member' }, json: true }; // invite users const inviteMember = { method: 'POST', url: xmpp_api_url + '/send_direct_invitation', headers: { 'Content-Type': 'application/json', Authorization: xmpp_auth }, body: { name: xmpp_muc_name, service: xmpp_muc_server, password: '', reason: 'vXMPPb Meeting Invite', users: key }, json: true }; request(addMember, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); request(inviteMember, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); } }, 2000);