Making a simple outbound calls using AMI node client

hi everyone , here i need some help i am using asterisk 13 with sip driver ,

i want to make an outbound call but i am facing issue

like call never reached to me , and duplicate calls

a lil help will be appreciated

here below is the sample code

const AmiClient = require('asterisk-ami-client');

const fs = require('fs');

const client = new AmiClient();

async function startCampaign() {

try {

await client.connect('magnus', 'admin', { host: '127.0.0.1', port: 5038 });

console.log("✅ Connected to AMI");

// Load numbers from txt

const numbers = fs.readFileSync('numbers.txt', 'utf-8').split('\n').filter(Boolean);

for (let number of numbers) {

console.log(`📞 Dialing ${number}`);

try {

let res = await client.action({

Action: 'Originate',

Channel: `Local/start@campaign`, // call out using peer 34166

Context: 'campaign', // must exist in extensions.conf

Exten: 'start',

Priority: 1,

CallerID: '18017017476',

Async: true,

Variable: `DIAL_NUMBER=${number}`

});

console.log("✅ Originate sent:", number);

} catch (err) {

console.error("❌ Originate error:", err);

}

}

// Listen for events

client.on('event', event => {

if (event.Event === 'Hangup') {

console.log(`❌ Call hangup: ${event.CallerIDNum} - Cause: ${event.CauseTxt}`);

}

if (event.Event === 'Dial') {

console.log(`☎️ Dial event: ${JSON.stringify(event)}`);

}

});

} catch (err) {

console.error("❌ Connection error:", err);

}

}

startCampaign();

here is the dialplan

[campaign]
exten => start,1,NoOp(Starting Campaign Call for ${DIAL_NUMBER})
;same => n,Answer()
same => n,Dial(SIP/vip1/${DIAL_NUMBER},30)
;same => n,Playback(custom/script)            ; play audio
same => n,Background(custom/script)          ; allow DTMF during playback
same => n,WaitExten(5)              ; wait 5 seconds for input
same => n,Hangup()

; If user presses 1
exten => 1,1,NoOp(Caller pressed 1 -> send to queue)
same => n,Queue(agents,t) ; bridge caller to available agent in 'sales'
same => n,Hangup()

looking for the response :slight_smile:

Did you use AI to write this? Do you have any Asterisk experience, or knowledge of dialplan?

The AMI Originate is “Place a call to the start extension in the context campaign” and once answered “Go to the start extension in the context campaign”. In this context the first thing it does dial an outgoing call. So, as written, it’s calling out and once answered calling the same thing and connecting the two.

YEA , I AM EXPLORING IT , a beginner .

and i appreciate for ur response ,
can u attach an example code for making an outbound call i tried all the thing but nothing worked

my goal is :
ami orignate (outbound using my provider ) —→ if user picked play an audio —–> if user pressed 1 connect call to the available agent .