FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
kamilchm
kamilchmGitHubCommunityActions
Public
Like
GitHubCommunityActions
Home
Code
2
README.md
C
github-discussions-monitor.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

GitHub Discussions Monitor

This Val Town application monitors a GitHub repository for new discussions and sends email notifications when new discussions are created.

Features

  • Monitors a GitHub repository for new discussions
  • Sends email notifications for new discussions
  • Keeps track of which discussions have already been processed
  • Can be scheduled to run at regular intervals

Setup Instructions

  1. Set up environment variables:

    • GITHUB_TOKEN: A GitHub personal access token with permissions to read discussions in the repository
  2. Configure the monitor:

    • Open the github-discussions-monitor.ts file
    • Update the REPO_OWNER and REPO_NAME variables with your target repository information
    • Optionally, set EMAIL_NOTIFICATIONS to false if you don't want email notifications
  3. Set up a cron trigger:

    • In the Val Town web UI, set up a cron trigger for this val to run at your desired frequency
    • Recommended: Every hour (0 * * * *)

How It Works

  1. The script fetches the most recent discussions from the specified GitHub repository using the GitHub GraphQL API
  2. It compares the fetched discussions with a list of previously processed discussions stored in Val Town's blob storage
  3. For each new discussion, it sends an email notification with details about the discussion
  4. It updates the list of processed discussions to include the new ones

Response Format

When run, the function returns a JSON object with the following structure:

{ "status": "success", "newDiscussions": 2, "discussions": [ { "id": "D_kwDOG7...", "title": "New feature request", "url": "https://github.com/owner/repo/discussions/123", "author": "username", "category": "Ideas" }, ... ] }

Or in case of an error:

{ "status": "error", "message": "Error message details" }

Customization

  • Email Format: You can customize the email format by modifying the sendNotificationEmail function
  • Discussions Query: You can adjust the GraphQL query in fetchGitHubDiscussions to change how discussions are fetched
  • Storage Key: You can change the STORAGE_KEY if you want to use a different key for blob storage

Troubleshooting

  • If you're not receiving notifications, check that your GitHub token has the correct permissions
  • Ensure the repository has discussions enabled
  • Check the Val Town logs for any error messages
Cron
  • github-discussions-monitor.ts
Code
README.md
C
github-discussions-monitor.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesCLIAI agentsCode intelligenceSlack integrationsGTMPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.