AGIDemo/index.js
2026-06-21 06:39:50 -06:00

25 lines
864 B
JavaScript

const agi = require("asteriskagi")
const x = new agi({port: 4578})
x.on('call', async (call) => {
const { remoteServer, uniqueid, context, extension, priority, calleridname, callerid, channel } = call;
call.on("hangup", () => {
console.log(`Hangup ${remoteServer}/${channel}`);
});
call.on("error", (err) => {
console.error(`ERROR: ${remoteServer}/${channel}: ${err}`);
});
console.log(`Call from ${callerid} (${calleridname}) to ${extension} in context ${context} on channel ${channel} with uniqueid ${uniqueid}`);
await call.Playback("beep");
while (true) {
await call.ReadExten("EXTEN_INPUT", "beep");
const exten = await call.getVariable("EXTEN_INPUT");
console.log(`Got ${exten}`);
if (!exten) break;
}
await call.Playback("goodbye");
await call.Hangup();
})