I have created an ARI application based on the information provided [url][wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Handling+DTMF#ARIandChannels:HandlingDTMF-JavaScript(Node.js)/url]
I can get it to play recordings but I will not take DTMF signals and play the next prompt(or wait for user input).
Asterisk Verison 13.4.0
[code]
/jshint node:true/
‘use strict’;
var ari = require(‘ari-client’);
var util = require(‘util’);
ari.connect(‘http://localhost:8088’, ‘asterisk1’, ‘asterisk’, clientLoaded); //not really access info.
var menu = {
// valid menu options
options: [1, 2],
// note: test one question
sounds: [‘q1_wouldyouhire’, ‘q2_wereyousatisfied’],
soundsIndex: [0]
};
var timers = {};
// Handler for client being loaded
function clientLoaded (err, client) {
if (err) {
throw err;
}
client.on(‘StasisStart’, stasisStart);
client.on(‘StasisEnd’, stasisEnd);
// Handler for StasisStart event
function stasisStart(event, channel) {
console.log(‘Channel %s has entered the application’, channel.name);
//channel.on('ChannelDtmfReceived', dtmfReceived);
channel.answer(function(err) {
if (err) {
throw err;
}
playOpener(channel);
// playIntroMenu(channel);
});
}
function playOpener(channel) {
console.log('playOpener was called');
var playback = client.Playback();
channel.play({media: ['sound:q1_wouldyouhire', 'sound:45700001']}, playback, function(err, newPlayback) {
// ignore errors
if (err) {
throw err;
}
});
}
// Handler for StasisEnd event
function stasisEnd(event, channel) {
console.log(‘Channel %s has left the application’, channel.name);
// clean up listeners
// channel.removeListener(‘ChannelDtmfReceived’, dtmfReceived);
//cancelTimeout(channel);
}
client.start(‘survey’);
}[/code]