-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
voice helpers #15
Comments
also, ES6 does not support named parameters 👎 - so, maybe pass an options object instead. and have this as the only argument, to just have this as the only named parameter object. then the only drawback is that with that we won't have default values for parameters? @pbombo and also how can we return the responses in commands? When we are done with the response build - maybe a so, basically this would be an xml var options = {
...
}
var response0 = voice.say("Hey, whatever", options);
var response1 = voice.command(options);
resp.end(response); |
Passing an options object seems like a decent compromise and it could still have default values something like below is still possible function (options) {
var someSetting = options.someSetting || defaultValue;
} |
This is also looking interesting, default parameters in ES6 |
I think my reaction was "JS can do that?" lol, I assumed it would, it's very pythonic. Better than Problem is, the default value is within options, so it's not on call. This would have been great with named parameters. |
I think it can be done well even without named parameters. Something like this would be nice: let str = "Salut!", anotherStr, url;
let options = { // action's secondary attributes as needed
voice: 'dude',
record: false
//...
};
voice.say(str, options)
.play(url)
.then(success)
.catch(error);
voice.getDigits(options)
.say(str, options)
.then(success)
.catch(error); But quick question: Is the documentation at http://docs.africastalking.com/voice up to date? I remember @ianjuma you said there were some big changes coming to voice... 😕 |
@aksalj I think the idea was to avoid user having to do this let options = { // action's secondary attributes
voice: 'dude',
record: false
//...
}; that is the real value of default parameters IMO. Ideally you'd just have |
@ianjuma is the problem named parameters or default parameters? With named params (which is what I think @ianjuma was referring to) you can have both this: let options = { // only set the options you need, otherwise default values will be used
voice: 'Female',
record: false
//...
};
voice.say(str, options);
// if you don't need to override the default options, just do
voice.say(str); Then |
I think both, ES6 doesn't support it, this could have been more readable. @aksalj some of the commands were updated, and there parameters too. now, order of commands? How are we making this response. Responses are usually simple and straight forward. So, are we grabbing the response string and returning it? voice.say(str, options)
.play(url)
.then(success)
.catch(error); |
May I contribute to this discussion. I also go for having an options object. Considering the lack of default params and strong intellisense-like features, one ends up looking up the docs a lot just to remember the order of params. |
Could something like this be a good solution? // example (express)
app.post('/callback/voice', new AfricasTalking.VOICE.CallHandler((phoneCall) => {
var session = phoneCall.session;
//...
if (phoneCall.isActive) {
//...
} else if (phoneCall.isCompleted){
//...
}
var response = voice.builder()
.say("UI", {voice: "woman"})
.play("DEd")
.getDigits("SW", {say:{voice: "man"}})
//... more say(), play(), record(), etc.
.build();
phoneCall.respond(null, response);
})); |
that's perfect! awesome! this will make it so easy to build voice apps on node 💯 |
@ianjuma is the voice library in AT node package updated with |
the voice helpers are very interesting; what approach do we take? plain xml response? or command to construct xml ? The helpers will be great, this will make voice so easy 👍
Here the approach is to wrap
say
around root xml response - what of nested commands? and attributes, how to create the xml response?Of course this is for incoming calls, with the callback url handler.
voice.call
is ok. I don't think there's much there. I mean initiating a call.Say
thenPlay
a URLand how do we wrap
getDigits
when wesay
?call redirect?
then, this would be expected.
maps to
Problem with this is that we need all possible mappings, and I think there's many cases, we might miss a few and not generate a proper functional XML string, but the XML response will still work.
So, basically we generate this by passing attributes on a command, is this a good approach?
we also need a SIP section, will look at this later.
The text was updated successfully, but these errors were encountered: