Asteroid App is an automated WhatsApp account that provides information about the asteroids closest to Earth.
When someone sends a WhatsApp message to your Twilio phone number, Twilio sends the request to your API endpoint. The API then tries to parse the request. It makes sure they're asking for closest asteroids to earth and that they provide valid dates (or no dates, in which case today will be assumed). If the validation is successful, it'll make a request to NASA's NeoWs API and format and return the result as a WhatsApp message. Otherwise, it will fetch a random fact from Cat Facts API and send a WhatsApp message apologising for not being able to understand the user's request and offering a random cat fact as consolation.
- Node.js web server using Express.js
- Twilio's WhatsApp API
- NASA's NeoWs API
- Cat Facts API
- Create a copy using GitHub's repository template functionality
- Update the
README.md
andpackage.json
with the respective values.
- Node.js
- A Twilio account - sign up
- An API key for NASA's open APIs
Asteroid App requires to configure environment variables related to NASA and the port on which the server is to listen for incoming requests. You should declare the following environment variables:
Key | Description |
---|---|
NASA_API_KEY | Your key to the NASA API. You can get one on their website |
NASA_HOST | It should have the following value: api.nasa.gov . |
NASA_PATH | It should have the following value: /neo/rest/v1/feed . |
PORT | The port on which you want your server to be available. |
After the above requirements have been met:
- Clone this repository and
cd
into it
git clone git@github.com:SavagePixie/asteroid-app.git
cd asteroid-app
- Install dependencies
npm install
- Run the application in dev mode
npm run dev
- After you're happy with all your changes, deploy the application in your server and start node
npm start
- On your Twilio dashboard, configure your WhatsApp sandbox. To do so, after you've deployed your application, set the option
WHEN A MESSAGE COMES IN
in your WhatsApp sandbox to your server's url followed by/api
(e.g.https://www.example.url.net/api
)
This project is set to be automatically deployed using Heroku. If you want to use any other means to deploy it, you can simply delete the .circleci
folder.
No warranty expressed or implied. Software is as is.