Originate failed without further information

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?

If you are dialing a number and doing no other processing, you should consider the application variant of originate.

However if you need to know appropriate context and and extensions, you should be asking on the FreePBX forum, as FreePBX controls the dialplan.

Sorry, what do you mean with “application variant”?

The one with the application and data parameters, rather than the context, extension and priority ones.

Do you have a link for the docs?

For me, this page

https://wiki.asterisk.org/wiki/display/AST/Asterisk+15+ManagerAction_Originate

makes it not easy to get into Asterisk development.

@david551 let’s say there would be no FreePbx and I would like to use the Asterisk engine with the Asterisk-Manager module (NodeJs) only.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerAction_Originate

Thanks, I already read these posts. My problem is I don’t know what the parameters stand for.

I’d suggest getting a grasp on that kind of aspect before diving into AMI and origination. The parameters and their meaning are core to the way Asterisk routes and handles calls.