I use the Asterisk engine with the FreePBX administration panel. For tests I use Phoner. I want to originate a call to a given number. For now I just want to originate a call from one extension to another (for testing purposes). If that works I would try to call a “real” phone number.
For the coding part I use NodeJs with the Asterisk-Manager module (https://www.npmjs.com/package/asterisk-manager)
Multiple extensions of type pjsip got configured with the FreePBX.
This is my phone module:
const asterisk = require('asterisk-manager');
const { port, host, user, password, events } = require('../config.json').phone;
const ami = new asterisk(port, host, user, password, events);
ami.keepConnected();
module.exports = () => {
ami.action({
action: 'originate',
channel: `SIP/007`,
exten: 111,
context: 'default',
priority: 1
}, (err, res) => {
if (err) {
// throw err;
console.log(err.message);
return;
}
console.log(res);
});
};
I took this resource for my code
https://wiki.asterisk.org/wiki/display/AST/Asterisk+15+ManagerAction_Originate
When I want to call someone I have to pass in the target phone number to the channel? Like SIP/${targetPhoneNumber}
?
What is the context and the priority?
When I execute my code I get the error “Originate failed” but no further information. What might be wrong?