I am trying to wrap my head around ARI and Asterisk, my goal is to dial from an extension to another. I dialed 5001 from extension 5002. Now in the stasisStart function, I want to create a new channel, and used the dialed number (5001) and pass 'PJSIP/5001' to the endpoint. How do I get the dialed number?
Dialplan:
exten => _500Z, 1, Stasis(test-app)
test-app.js
function stasisStart(event, channel) {
// I want to dial 'PJSIP/5001' (the dialed number)
client.channels.originate({ endpoint: 'PJSIP/5001', app: 'test-app' },)
.then(function (originatedChannel) {
console.log(' originated ');
console.log(util.format('originated channel id %s - name: %s', originatedChannel.id, originatedChannel.name));
})
.catch(function (err) { console.log('error happened'); });
}
Channel
id: "1603812843.140"
name: "PJSIP/5002-0000004e"
state: "Ring"
caller: {"name":"","number":"5002"}
connected: {"name":"","number":""}
accountcode: ""
dialplan: {"context":"internal","exten":"5001","priority":1,"app_name":"Stasis","app_data":"test-app"}
creationtime: "2020-10-27T11:34:03.251-0400"
language: "en"
I found this example that works. I guess I was confused about the endpoint, I thought I had to specify it in the dialplan, but not.