Skip to content

Instantly share code, notes, and snippets.

@jjoocceeee
Created September 7, 2019 20:12
Show Gist options
  • Select an option

  • Save jjoocceeee/da80a5f6ffc2929b13a3afd82ca26f28 to your computer and use it in GitHub Desktop.

Select an option

Save jjoocceeee/da80a5f6ffc2929b13a3afd82ca26f28 to your computer and use it in GitHub Desktop.
Function to handle the Get Today's Holidays Intents
async function getTodayHolidays(handlerInput){
const { requestEnvelope, attributesManager, responseBuilder } = handlerInput;
const { intent } = requestEnvelope.request;
let response = await axios({
url: 'Replace Me With URL at bottom of Blog post',
method: 'post',
data: {
query: `
query
{
holidaysToday{
name
}
}
`
}
});
let holidayText = 'Todays holidays are';
if(response.data.length < 1){
holidayText='There are no holidays today. We can celebrate you instead?';
return holidayText;
} else {
_.forEach(response.data.data.holidaysToday, (day)=>{
holidayText+= " " + day.name + ",";
});
}
return handlerInput.responseBuilder.speak(holidayText).getResponse();
// return holidayText;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment