Open unique1o1 opened 3 years ago
Use a function like this (outboundCalll) to make outbound calls. Take into consideration the following:
` import Ari from 'ari-client';
const outboundCalll = async () => { try { const url = 'http://myasterisk.com:8088/ari'; const username = 'asterisk'; const password = 'asterisk';
const client = await Ari.connect(url, username, password);
console.log(`Connected to ${url}`);
client.on('StasisStart', async (event, channel) => {
console.log('call answered:', JSON.stringify(event));
// Ignore other channels entering the application (e.g. snoop channels).
if (event.args[0] !== 'dialed') return;
channel.once('ChannelHangupRequest', () => {
console.log('ChannelHangupRequest');
});
// Your code here
});
const endpoint = 'PJSIP/1235551234@outbound';
const app = 'channel-dump';
client.start(app, async err => {
if (err) return console.log('application start error:', err);
console.log('application started!');
try {
const outChannel = client.Channel();
outChannel.on('ChannelDestroyed', (event, channel) => {
console.log('channel destroyed', channel.id);
});
await outChannel.originate({
endpoint,
app,
appArgs: 'dialed',
});
console.log('channel created:', outChannel.id);
} catch (error) {
console.log('error while creating channel:', error);
}
});
} catch (err) {
console.log(err);
}
}; `
I'm new to asterisk and I'm having trouble grasping all the nuances.
I have successfully made calls to inbound extension using the originate function and played some audio files. But now I need to call real-world phone numbers. I have already set up sip trunk in my asterisk config but I'm having an issue calling through sip/trunk.
Running the following code just gives me an
allocation failed
error.Can anyone point me in the right direction? Thanks