WhatsApp Wikipedia Bot

A Wikipedia-style bot that can be integrated with WhatsApp to provide fun facts, audio clips, and video content on demand.

Features

  • Respond to user queries with relevant fun facts
  • Send MP3 audio clips on request
  • Share MP4 video content when requested
  • Toggle between different content types
  • Remember user preferences

Project Structure

  • /backend/index.ts - Main HTTP endpoint for WhatsApp webhook
  • /backend/database/ - SQLite database setup and queries
  • /backend/handlers/ - Message handling logic
  • /backend/content/ - Content management for facts, audio, and video
  • /shared/ - Shared types and utilities

Setup

  1. Set up a WhatsApp Business API account or use a service like Twilio
  2. Configure the webhook URL to point to this Val
  3. Set the following environment variables:
    • WHATSAPP_VERIFY_TOKEN - For webhook verification
    • WHATSAPP_TOKEN - Your WhatsApp Business API token
    • WHATSAPP_PHONE_NUMBER_ID - Your WhatsApp phone number ID
    • ADMIN_API_KEY - Secret key for accessing admin endpoints

Usage

Users can interact with the bot using commands:

  • !fact - Get a random fun fact
  • !audio - Get a random audio clip
  • !video - Get a random video
  • !fact [topic] - Get a fact about a specific topic
  • !help - Show available commands

Development

This project uses SQLite for storage and is built to run on Val Town.