Cosmo!
- 4 Devlogs
- 3 Total hours
Cosmo-bot brings cat facts, jokes, NASA's Astronomy Picture of the Day, and more right into your Slack workspace via slash commands. And it replies to messages 24/7!
Cosmo-bot brings cat facts, jokes, NASA's Astronomy Picture of the Day, and more right into your Slack workspace via slash commands. And it replies to messages 24/7!
Today I successfully deployed Cosmo on Nest.
Previously, I have to keep my laptop open and a the program just keeps runnig to keep the bot alive.
It was hosted on Nest, Cosmo runs 24/7 in the cloud.
It is completely independent of my laptop, always online and ready to respond to slash commands in the slack workspace anytime even when I am sleeping
/csb-orbit
This feature lets users see exactly how many humans are currently orbiting the earth with their names and spacecraft.
When the user runs this command the bot makes the request to Open-Notify Astros API.
Then API gives the JSON data containing no. of Astronauts in array of objects with each persons spacecraft.
And the bot give the result in the chat.
I have been spending a lot of time trying to make Cosmo feel like an actual interactive, instead of just blank script. I finally got a bunch of custom slash commands working in my Slack workspace, but man, getting here was a bit of a headache.
/csb-ping - Just simple command to check the latency of bot response. Used to make sure the bot is working and not crashed./csb-catfact & /csb-joke - I have added these for a bit random fun. It just instantly give you a cat-fact and a joke./csb-apod - This was the biggest task to code but it is easily one of coolest feature. It pings NASA’s Astronomy Picture of the Day API and give you Title, Image and Description of APOD.At first, dealing with external JSON payloads was a mess. I kept hitting API errors trying to parse NASA’s response. I had to figure out how to manually dig into the JSON, extract the exact image URL, title, and description, and then map it into JavaScript. As NASA send it’s API data little slowly if many accessed at same time. So I add a wait period of 3s. So if it get the repose it displays it, if it throws a fails to fetch.
Today I spend my day by adding a new feature /csb-apd.
It’s basically a slash commond the calls NASA’s Astronomy Picture of the Day API and brings the data over to Slack. It sounds simple while hearing it. But getting data from external JSON and displaying the image is real trial and error. I had extract the image URL , title and description from NASA’s response. Then map them into the js for the slash command /csb-apd reference and sent it as nice media card.
Seeing the Pluto image finally render perfectly in the channel after hitting a few api errors was a massive win. Greatfully learned about API and there usability and integration in to any system or projects.