Last active
February 24, 2025 17:32
-
-
Save jfinstrom/560ef51b455fb5c27a27e6545c909182 to your computer and use it in GitHub Desktop.
ari thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright © 2019 James Finstrom <[email protected]> | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. | |
* | |
* npm install ari-client | |
* npm install request | |
* Asterisk Dialplan | |
* Copied From: https://wiki.asterisk.org/wiki/display/AST/Getting+Started+with+ARI | |
* exten => 1000,1,NoOp() | |
* same => n,Answer() | |
* same => n,Stasis(sendhook) | |
* same => n,Hangup() | |
* run: nohup node arithing.js & | |
* probably better to use PM2 or something to manage the process ¯\_(ツ)_/¯ | |
* get the ari user and password from /etc/asterisk/ari.conf | |
* Yes there are 19 lines of comments for 10 lines of code. You're welcome | |
*/ | |
var client = require('ari-client'); | |
var request = require('request'); | |
client.connect('http://localhost:8088/ari/', 'username', 'password',function(err,ari){ | |
ari.on('StasisStart',function(event,channel){ | |
request.post('https://postb.in/1568770796124-5495820760261').form({"channel":event.channel}); | |
channel.continueInDialplan(); | |
}); | |
ari.start('sendhook'); | |
}); |
yes you would just change the endpoint and the post data (within form();)
This example uses https://www.npmjs.com/package/request which was valid when this was made and is now deprecated so a different library may want to be used. It may be worth using a one signal client https://www.npmjs.com/package/onesignal and only use the parts of channel you need.....
let message = `Call From ${channel.callerid.name (${channel.callerid.number})}`
Thank you very much, will give it a try. Cheers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could this be modified to notify via Push to onesignal ? https://documentation.onesignal.com/reference#create-notification
Thanks for sharing.