This document explains how to set up the scheduler for the Twitter data ingestion process in Val Town.
The Twitter data ingestion process is implemented as a cron job in Val Town. This job fetches tweets from the Twitter API, processes them through our filtering pipeline, and stores them in the database. The scheduler runs this job at regular intervals to ensure timely and consistent data updates.
As per the Val Town documentation, cron schedules cannot be configured programmatically via code. Instead, they must be set up through the Val Town web GUI.
Upload the Cron File:
twitter-fetch.cron.ts
file is uploaded to your Val Town account.cron.ts
extension to indicate it's a cron jobConfigure Schedule in Val Town Web GUI:
twitter-fetch.cron.ts
val0 */3 * * *
for every 3 hours)Recommended Schedule:
0 */1 * * *
to 0 */3 * * *
)The cron job requires the following environment variables to be set in your Val Town environment:
TWITTER_BEARER_TOKEN
: Your Twitter API bearer tokenEMAIL_TO
(optional): Email address to send notifications toAUTH_USERNAME
and AUTH_PASSWORD
: Credentials for accessing the test endpointsTWITTER_FILTER_*
(optional): Various filter configuration optionsFor testing or one-off runs, you can manually trigger the cron job using the test endpoint:
https://your-val-town-username.web.val.run/twitter-test
This endpoint requires basic authentication using the AUTH_USERNAME
and AUTH_PASSWORD
environment variables.