Fix Invalid Response, cleanup (#12)
This commit is contained in:
parent
1422d49c31
commit
e09ee66d1c
@ -15,7 +15,7 @@ Function](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/d
|
||||
|
||||
## Configuring The Skill
|
||||
|
||||
To configure the skill, open up the `.env` file and fill in the correct values for `CP_URL`, which
|
||||
To configure the skill, copy `default.env` to `.env` and fill in the correct values for `CP_URL`, which
|
||||
should point to your Couch Potato server, and `CP_API_KEY` which should have your server's API key.
|
||||
|
||||
## Testing The Skill Locally
|
||||
@ -40,7 +40,7 @@ in the Sample Utterances field, copy and paste the contents of
|
||||
|
||||
The skill is built to be easily hosted on Amazon's [AWS
|
||||
Lambda service](https://aws.amazon.com/lambda/). Create your Lambda function (using the
|
||||
alexa-skills-kit-color-expert blueprint) and make sure you choose Node.js as the runtime. After
|
||||
alexa-skills-kit-color-expert blueprint) and make sure you choose Node.js as the runtime. After
|
||||
you've created your Lambda function, look at the top right of the page to get your Lambda ARN
|
||||
number and put that in the Alexa Skill Information Endpoint field.
|
||||
|
||||
|
@ -9,4 +9,4 @@ AWS_TIMEOUT=10
|
||||
AWS_DESCRIPTION=
|
||||
AWS_RUNTIME=nodejs
|
||||
CP_URL=http://url-to-couch-potato-server
|
||||
CP_API_KEY=apiKey
|
||||
CP_API_KEY=APIKEY
|
@ -54,12 +54,12 @@ function handleFindMovieIntent(req, resp) {
|
||||
|
||||
function handleAddMovieIntent(req, resp) {
|
||||
var movieName = req.slot('movieName');
|
||||
|
||||
|
||||
cp.movie.search(movieName,5).then(function (movies) {
|
||||
movies = utils.formatSearchResults(movies);
|
||||
utils.sendSearchResponse(movies, movieName, resp);
|
||||
});
|
||||
|
||||
|
||||
//Async response
|
||||
return false;
|
||||
}
|
||||
|
17
lib/utils.js
17
lib/utils.js
@ -18,7 +18,7 @@ function buildPrompt(movies) {
|
||||
}
|
||||
|
||||
function sendSearchResponse(movies, movieName, resp) {
|
||||
|
||||
|
||||
if(!movies || !movies.length > 0) {
|
||||
return resp.say('No movie found for ' + movieName).send();
|
||||
}
|
||||
@ -31,24 +31,24 @@ function sendSearchResponse(movies, movieName, resp) {
|
||||
}
|
||||
|
||||
function formatSearchResults(movies) {
|
||||
|
||||
|
||||
var newMovies = [];
|
||||
|
||||
|
||||
if (movies != undefined) {
|
||||
|
||||
for (var i = 0; i < movies.length; i++) {
|
||||
|
||||
newMovies.push({
|
||||
original_title: movies[i].original_title,
|
||||
inLibrary: movies[i].in_library,
|
||||
in_library: movies[i].in_library,
|
||||
year: movies[i].year,
|
||||
titles: movies[i].titles,
|
||||
imdb: movies[i].imdb
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return newMovies;
|
||||
|
||||
return newMovies;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@ -56,4 +56,3 @@ module.exports = {
|
||||
sendSearchResponse: sendSearchResponse,
|
||||
formatSearchResults: formatSearchResults
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user