Skip to content

Instantly share code, notes, and snippets.

/*
Set timers in the AM to wake device and keep Digital Signage running
Timers in the PM allow device to go into standby but wake when
someone enters the room but digital signage only plays for short amount of time once in halwake state
*/
import xapi from 'xapi';
const Sunday = 0, Saturday = 6;
async function callHistory() {
const history = await this.xapi.command("CallHistory Recents", {Limit: 1, DetailLevel: "Full"});
console.log(history);
return history;
}
function getServiceNowIncidentIdFromURL(url){
return xapi.command('HttpClient Get', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':url, 'AllowInsecureHTTPS': 'True'});
}
function raiseTicket(message){
console.log('Message raiseTicket: ' + message);
var messagecontent = { description: systemInfo.softwareVersion , short_description: message };
xapi.command('HttpClient Post', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':MONITORING_URL, 'AllowInsecureHTTPS': 'True'}
@voipnorm
voipnorm / OnlineMeetingMacro.js
Last active October 2, 2019 21:47
Online Meeting Button Macro
const xapi = require('xapi');
const MYSITE = '<yourWebexSite>.';
const domain = "webex.com";
var meetingID = '';
const REGEXP_WEBEX = /(webex.com)$/;
const REGEXP_ALPHA = /^[a-zA-Z]+$/;
const REGEX_WEBEXID = /^\d{9}$/;
const REGEXP_AT =/^.+@.+$/;
function onlineMeeting() {
xapi.event.on('UserInterface Message Prompt Response', (event) => {
switch(event.FeedbackId){
case 'roomfeedback_step1':
switch(event.OptionId){
case '1':
xapi.command("UserInterface Message TextInput Display", {
Duration: 0
, FeedbackId: "roomfeedback_step2_cleanliness"
, InputType: "SingleLine"
, KeyboardState: "Open"
xapi.event.on('UserInterface Extensions Panel Clicked', (event) => {
if(event.PanelId == 'reportissue'){
xapi.command("UserInterface Message Prompt Display", {
Title: "Report issue"
, Text: 'Please select what the problem area is'
, FeedbackId: 'roomfeedback_step1'
, 'Option.1':'Cleanliness'
, 'Option.2':'Technical issues with Audio/Video'
, 'Option.3': 'Other'
}).catch((error) => { console.error(error); });
tp.on('status', (report) => {
console.log(report);
if(report.state === 'lights'){
if(report.status === 'on'){
lights(true);
}else{
lights(false);
}
}else{
monitorWidget() {
this.xapi.event.on('UserInterface Extensions Widget Action', (event) => {
const msg = `id=${event.WidgetId} / type=${event.Type} / value=${event.Value}`;
console.log(msg);
if(event.WidgetId === 'office'){
return this.emit('status', {state: 'lights', status: event.Value});
}else{
return this.emit('status', {state: 'dimmer', status: event.Value});
}
})
@voipnorm
voipnorm / kasaBulbId.js
Created September 17, 2019 15:53
Kasa light project find bulb ID
"use strict";
const KasaControl = require('kasa_control');
const kasa = new KasaControl();
const email = "email;
const password = "password";
async function main() {
const xapi = require('xapi');
xapi.event.on('UserInterface Extensions Panel Clicked', (event) => {
if(event.PanelId === "chris-pmr"){
xapi.command("dial", {Number: 'chris@site.webex.com'}).catch((error) => { console.error(error); });
}
});