Skip to content

Commit

Permalink
Handle utterance parsing not being able to pick up a movie title.
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschmitt committed May 29, 2017
1 parent dfdf440 commit 0ad726f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CANCEL_RESPONSE,
HELP_RESPONSE,
NO_MOVIE_FOUND,
NO_MOVIE_SLOT,
WELCOME_DESCRIPTION
} from '~/lib/responses.js';

Expand All @@ -32,6 +33,10 @@ export default function handleLaunchIntent(req, resp) {
}

export function handleFindMovieIntent(req, resp) {
if (!req.slot('movieName')) {
return resp.say(NO_MOVIE_SLOT()).send();
}

const query = buildMovieQuery(req);

return cp.get('movie.list', {
Expand Down Expand Up @@ -63,6 +68,10 @@ export function handleFindMovieIntent(req, resp) {
}

export function handleAddMovieIntent(req, resp) {
if (!req.slot('movieName')) {
return resp.say(NO_MOVIE_SLOT()).send();
}

return cp.get('movie.search', {
q: buildMovieQuery(req)
}, NUM_RESULTS).then(({movies}) => {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const HELP_RESPONSE = tmpl`You can ask Couch Potato about the movies in y
/** ${0: Search query} */
export const NO_MOVIE_FOUND = tmpl`Couldn't find ${0} in your wanted list.`;

export const NO_MOVIE_SLOT = tmpl`Sorry, I couldn't understand the movie title I heard. Please try
again with different phrasing.`;

export const REPROMPT_END = tmpl`Ok, I'm out of suggestions.`;

/** ${0: Movie Title}, ${1: Release date} */
Expand Down

0 comments on commit 0ad726f

Please sign in to comment.