Created
September 7, 2019 20:12
-
-
Save jjoocceeee/da80a5f6ffc2929b13a3afd82ca26f28 to your computer and use it in GitHub Desktop.
Function to handle the Get Today's Holidays Intents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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