Automated AI news content creator that fetches tech news, generates Myanmar language content with AI-generated images, and posts to Facebook pages.
- Fetches AI/tech news from GNews API
- Generates Myanmar language content using AI (OpenAI-compatible API)
- Generates images using AI (Gemini image models)
- Posts to Facebook pages with images and hashtags
- Scheduled posting via Cloudflare Workers cron
- Custom AI gateway support (OpenRouter, local gateway, etc.)
- Runtime: Cloudflare Workers
- Language: TypeScript
- AI Provider: OpenAI-compatible API (supports Gemini, OpenRouter, custom gateways)
- News Source: GNews API
- Social: Facebook Graph API
pnpm installCopy .dev.vars.example to .dev.vars:
cp .dev.vars.example .dev.varsEdit .dev.vars:
# AI Provider Config (OpenAI-compatible)
AI_API_KEY=your_api_key
AI_TEXT_MODEL=google/gemini-2.5-flash
AI_IMAGE_MODEL=google/gemini-2.5-flash-image
AI_API_ENDPOINT=https://your-ai-gateway.com/v1
# Facebook Config
FB_ACCESS_TOKEN=your_page_access_token
FB_PAGE_ID=your_numeric_page_id
# News Config
GNEWS_API_KEY=your_gnews_api_key- Create app at developers.facebook.com
- Add "Facebook Login for Business" product
- Go to Use cases → Manage everything on your Page → Customize
- Add
pages_manage_postspermission - Generate a Page Access Token (not User token)
- Get your numeric Page ID from Page settings
Required permissions:
pages_manage_posts- for posting contentpages_read_engagement- for reading page data
The app uses OpenAI-compatible API format. You can use:
- OpenRouter:
https://openrouter.ai/api/v1 - Google AI Studio:
https://generativelanguage.googleapis.com/v1beta/openai/ - Custom gateway: Your own proxy server
# Run local dev server
pnpm dev
# Test scheduled task locally
pnpm dev --test-scheduled
# Run tests
pnpm test:run
# Test specific features
pnpm test:run text # Test text generation
pnpm test:run image # Test image generation
pnpm test:run news # Test news fetching
pnpm test:run select # Test article selection
pnpm test:run token # Test Facebook token# Set secrets
wrangler secret put AI_API_KEY
wrangler secret put AI_API_ENDPOINT
wrangler secret put FB_ACCESS_TOKEN
wrangler secret put FB_PAGE_ID
wrangler secret put GNEWS_API_KEY
# Deploy
pnpm deployVisit https://your-worker.workers.dev/run to trigger content creation manually.
Generated posts include:
[Myanmar language content about the news]
#AI #ArtificialIntelligence #Tech #Innovation #Myanmar #နည်းပညာ
🔗 https://source-article-url.com
src/
├── index.ts # Main worker entry
├── types.ts # TypeScript types
└── modules/
├── createContent/
│ ├── ai.ts # AI text/image generation
│ ├── news.ts # News fetching
│ └── index.ts # Content creation pipeline
└── publishContent/
├── facebook.ts # Facebook API
└── index.ts # Publishing pipeline
Facebook Page tokens can expire. Regenerate from Graph API Explorer.
Ensure your app has pages_manage_posts permission and you're using a Page token (not User token).
Check if your AI gateway supports image generation via chat completions. Some models return images in message.images[] array.
Cloudflare Workers can't access localhost. Use production gateway URL in .dev.vars.
MIT