const xapi = require('xapi'); const numbers = { /* Edit Numbers */ 1: 'h323:192.168.1.1', 2: 'h323:192.168.1.1', 3: 'h323:192.168.1.1', 4: 'h323:192.168.1.1', 5: 'h323:192.168.1.1', }; function dial(number) { console.log('dial', number); xapi.command('dial', { Number: number }); } function listenToGui() { xapi.event.on('UserInterface Message Prompt Response OptionId', (event) => { const number = numbers[event]; console.log('dial', numbers.event); dial(number); }); } function setToGui(number) { xapi.command('CallHistory DeleteAll', {Filter: 'all'}); xapi.command('UserInterface Message Prompt Display', { Title: 'Information', Text: 'Select Language', FeedbackId: 'quick-dial', 'Option.1':'English', 'Option.2':'Japanese', 'Option.3': 'Chinese', 'Option.4': 'Korean', 'Option.5': 'Others', }); } xapi.event.on('UserInterface Message Prompt Cleared FeedbackId', () => { const p1 = xapi.status.get('SystemUnit State NumberOfInProgressCalls'); const p2 = xapi.status.get('SystemUnit State NumberOfActiveCalls'); Promise.all([p1, p2]).then(results => { const inProgress = results[0]; const active = results[1]; if (inProgress < 1 && active < 1) setToGui(); }); }); setToGui(); listenToGui(); xapi.event.on('CallDisconnect', (event) => {setToGui()}); xapi.event.on('CallSuccessful', (event) => {xapi.command('UserInterface Message Prompt Clear')});