Skip to content

Instantly share code, notes, and snippets.

@timelincoln7648
Created November 30, 2017 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timelincoln7648/968dc449bea3b7de7d7b492e06a98d51 to your computer and use it in GitHub Desktop.
Save timelincoln7648/968dc449bea3b7de7d7b492e06a98d51 to your computer and use it in GitHub Desktop.
/**
* Get Current Connected Xero Org
*/
app.intent('getOrgName', {
'slots': {},
'utterances': ['{which|what} {|zero} {org|organisation|account|company|file} {|am I} {connected|attached|looking} {|at|to|on|in}'],
}, function(req, res) {
return checkSession(req)
.then(function(xeroDataHelper) {
return xeroDataHelper.getOrgName()
.then(function(orgName) {
res.say(xeroDataHelper.formatOrgName(orgName)).shouldEndSession(false).send();
})
.catch(function(err) {
console.log(err.statusCode);
var prompt = 'I couldn\'t find the connected org for you. Sorry.';
res.say(prompt).shouldEndSession(true).send();
});
})
.catch(function(err) {
console.log(err);
res.linkAccount().shouldEndSession(true).say('Your Zero account is not linked. Please use the Alexa App to link your account.');
return true;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment