Daily AI Trigger (for Tianji)
A Cloudflare Workers-based scheduled trigger project for executing timed Tianji Survey AI-related tasks and summary generation.
Features
- Built on Cloudflare Workers
- Supports scheduled task triggering
- Developed with TypeScript
Development Requirements
- Node.js
- pnpm
- Wrangler CLI (Cloudflare Workers CLI tool)
Installation
pnpm install
Usage
Development
npm run dev:scheduled
Deployment
# Deploy to Cloudflare Workers
npm run deploy
Environment Variables
The project uses a .dev.vars file to manage local development environment variables. When deploying to production, ensure these environment variables are properly set in the Cloudflare Workers console.
Required Environment Variables
Tianji Configuration
BASE_URL: Base URL for Tianji APIAPI_KEY: Tianji API keyWORKSPACE_ID: Workspace ID, can be found in workspace informationSURVEY_ID: Tianji Survey IDPAYLOAD_CONTENT_FIELD: Field name for the main survey content (target for classification and translation)LANGUAGE: Language setting, e.g., 'en', helps Tianji AI generate results in the corresponding language
Feishu Configuration (Optional)
FEISHU_WEBHOOK: Feishu bot webhook URLFEISHU_APP_ID: Feishu application IDFEISHU_APP_SECRET: Feishu application secretFEISHU_TABLE_APPTOKEN: Feishu multi-dimensional table AppTokenFEISHU_TABLE_ID: Feishu multi-dimensional table ID
Local Development
- Create a
.dev.varsfile in the project root directory - Copy the above environment variables and fill in their respective values
Production Environment
In the Cloudflare Workers console, configure the same environment variables. Ensure all required environment variables are properly set.
Project Structure
src/- Source code directorywrangler.jsonc- Cloudflare Workers configuration fileworker-configuration.d.ts- Workers type definition file