Back to Templates

Daily Space Quiz Bot: NASA APOD to Slack with GPT-4 Turbo

Created by

Created by: Moka Ouchi || moka

Moka Ouchi

Last update

Last update 20 hours ago

Share


How it works

This workflow automates the creation and management of a daily space-themed quiz in your Slack workspace. It's a fun way to engage your team and learn something new about the universe every day!

  • Triggers Daily: The workflow automatically runs at a scheduled time every day.
  • Fetches NASA's Picture of the Day: It starts by fetching the latest Astronomy Picture of the Day (APOD) from the official NASA API, including its title, explanation, and image URL.
  • Generates a Quiz with AI: Using the information from NASA, it prompts a Large Language Model (LLM) like OpenAI's GPT to create a unique, multiple-choice quiz question.
  • Posts to Slack: The generated quiz is then posted to a designated Slack channel. The bot automatically adds numbered reactions (1️⃣, 2️⃣, 3️⃣, 4️⃣) to the message, allowing users to vote.
  • Waits and Tallies Results: After a configurable waiting period, the workflow retrieves all reactions on the quiz message. A custom code node then tallies the votes, identifies the users who answered correctly, and calculates the total number of participants.
  • Announces the Winner: Finally, it posts a follow-up message in the same channel, revealing the correct answer, a detailed explanation, and mentions all the users who got it right.

Set up steps

This template should take about 10-15 minutes to set up.

  1. Credentials:
    • NASA: Add your NASA API credentials in the Get APOD node. You can get a free API key from the NASA API website.
    • OpenAI: Add your OpenAI API credentials in the OpenAI: Create Quiz node.
    • Slack: Add your Slack API credentials to all the Slack nodes. You'll need to create a Slack App with the following permissions: chat:write, reactions:read, and reactions:write.
  2. Configuration:
    • In the Workflow Configuration node, set your channelId to the Slack channel where you want the quiz to be posted.
    • You can also customize the quizDifficulty, llmTone, and answerTimeoutMin to fit your audience.
  3. Activate Workflow: Once configured, simply activate the workflow. It will run automatically at the time specified in the Schedule Trigger node (default is 21:00 daily).

Requirements

  • An n8n instance
  • A NASA API Key
  • An OpenAI API Key
  • A Slack App with the appropriate permissions and API credentials