In this module we show how to access an external API (3rd party REST service) with the Axios library (you might use other libraries similarly, like e.g. node-fetch). We use async/await to wait for a response from the service. We set up a connection timeout so the call comes back in time before we run out of time during an Alexa conversation turn (typically 8 seconds). We use the Progressive Response API before doing the call so Alexa gives the user a nice waiting message if the connection takes a few seconds to return.
- Build Tab: add celebrity birthdays intent with utterances to ask for today's birthdays (no slots)
- Code Tab: add axios dependency to package.json
- Code Tab: add code to access external API (with async/await), axios allows to set a timeout (use 6500 ms)
- Code Tab: add progressive response directive and attach to external API call
- Code Tab: add celebrity birthdays intent handler
- Code Tab: add new handler to skill builder
- Fetch external API (async/await)
- Progressive Response
- lambda/custom/constants.js: add max birthdays to this file
- lambda/custom/package.json: add axios dependency
- lambda/custom/localisation.js: add all messages related to API access
- models/xx-XX.json: add celebrity birthdays intent with utterances to ask for today's birthdays
- lambda/custom/logic.js: add functions to return current date info and to call external API
- lambda/custom/util: add function to create progressive response directive (callDirectiveService)
- lambda/custom/index.js: Extend birthday greeting to mention celebrity birthdays. Add celebrity birthdays intent handler and fetch the birthdays from the API. Add new handler to skill builder