Yikes! That is awesome! I love playgrounds and new toys to play with. Sadly, I usually break them.
When I go to freepbx - npm and copy the “You can utilize FreePBX like so” script, then click on “Test with RunKit” it takes me to RunKit. I paste the script in the sandbox and click run, I get
Error: Cannot find module 'asterisk-manager'
at Module._resolveFilename in core internal/modules/cjs/loader.js — line 580
So I’m not sure exactly how to invoke.
When I installed ari-client I got warnings:
[root@agents ~]# npm install ari-client
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN deprecated [email protected]: No longer maintained, please upgrade to swagger-client@3.
npm WARN engine [email protected]: wanted: {"node":">= 4"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN deprecated [email protected]: The sprintf package is deprecated in favor of sprintf-js.
npm WARN engine [email protected]: wanted: {"node":">=6"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=6"} (current: {"node":"0.12.18","npm":"2.15.11"})
[email protected] node_modules/ari-client
âââ [email protected]
âââ [email protected]
âââ [email protected]
âââ [email protected]
âââ [email protected] ([email protected], [email protected])
âââ [email protected] ([email protected], [email protected])
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
When I installed FreePBX, I got 2.0.0 instead of 2.1.2:
[root@agents ~]# npm install http://mirror.freepbx.org/npm/freepbx-2.0.0.tgz --save
[email protected] node_modules/freepbx
âââ [email protected]
âââ [email protected]
âââ [email protected]
âââ [email protected]
âââ [email protected] ([email protected], [email protected], [email protected], [email protected])
Then when I tried to run it with node: (“it” being the “You can utilize FreePBX like so” script saved as freepbx.js)
[root@agents ~]# node freepbx.js
Unhandled rejection ReferenceError: Bluebird is not defined #different versions installed with ARI and FreePBX packages
at Conf.get (/var/www/html/fop2/node_modules/freepbx/dist/lib/Conf.js:80:13)
at /var/www/html/fop2/freepbx.js:11:16
at tryCatcher (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/var/www/html/fop2/node_modules/freepbx/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate [as _immediateCallback] (timers.js:367:17)
Then I tried the script https://github.com/asterisk/node-ari-client/blob/master/examples/originate.js:
[root@agents fop2]# node originate.js
[ 'This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info' ]
Being that I am an idiot, I did all this on a box about to go into production with a LOT of custom code. I hope I didn’t break anything important to FreePBX modules.
So, now I am confused and befuddled about what to do and how I should update what to get the sample scripts to run. Do you have any further guidance for me about how to configure and invoke something like originate.js or “You can utilize FreePBX like so” script? (And I will do all further playing on development box.) 
Thanks so much for your help!