Read something but forget where it was? Seen remembers what you have seen.
Seen is a simple personal knowledge management tool made for impatient people like me.
-
Dead simple, just send a link, and search later for whatever you still remember.
-
Just a simple telegram bot, no bloatware.
-
Cures your allergic to AI by using a lot of AI in this project: document processing, vector search, etc.
Let me know if you are interested in a hosted version of Seen.
Setting up the self-hosted version is a bit complicated. Please let me know if there are any issues. Self-hosting uses Cloudflare free-tier, should be more than enough for personal use.
Create a Telegram bot (from @BotFather) and get an API token.
Login to Cloudflare:
npx wrangler login
Clone this repository
git clone https://github.com/XiangpengHao/seen.git
cd seen
-
Add your Telegram bot token to Cloudflare Workers as a secret:
npx wrangler secret put BOT_TOKEN
When prompted, paste your Telegram bot token.
-
Get your Chat ID by sending a message to your bot and then visiting:
https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
Replace <BOT_TOKEN> with your actual bot token. Look for the
chat
object in the response and find yourid
. -
Add your Chat ID to the environment variables in your wrangler.toml file:
[vars] AUTHORIZED_CHAT_IDS = "YOUR_CHAT_ID"
Replace YOUR_CHAT_ID with the chat ID you obtained in the previous step. For multiple authorized users, separate IDs with commas: "ID1,ID2,ID3".
Add your CloudFlare account ID and API token to Cloudflare Workers as secrets:
npx wrangler secret put CF_ACCOUNT_ID
npx wrangler secret put CF_API_TOKEN
Seen use Gemini to process documents. You can get a free API key from Gemini API.
Add your Gemini API key to Cloudflare Workers as a secret:
npx wrangler secret put GEMINI_API_KEY
npx wrangler d1 create seen
Now you should copy the output to the corresponding field in wrangler.toml
, e.g.
[[d1_databases]]
binding = "SEEN_DB"
database_name = "seen"
database_id = "bba483bb-4377-46f1-a8d4-df83772edc95"
Configure the database:
npx wrangler d1 execute seen --command "SQL_BELOW" --remote
CREATE TABLE IF NOT EXISTS links (
id TEXT PRIMARY KEY,
url TEXT NOT NULL,
created_at TEXT NOT NULL,
bucket_path TEXT NOT NULL,
content_type TEXT NOT NULL,
size INTEGER NOT NULL,
title TEXT NOT NULL,
summary TEXT NOT NULL,
chunk_count INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_links_url ON links(url);
CREATE INDEX IF NOT EXISTS idx_links_id ON links(id);
npx wrangler vectorize create seen-index --dimensions=768 --metric=cosine
Build and deploy your bot to Cloudflare Workers:
npx wrangler deploy
This will deploy your bot and give you a URL (something like https://your-bot.your-username.workers.dev
).
Tell Telegram where to send updates by setting up a webhook. Open a browser and navigate to:
https://api.telegram.org/bot<BOT_TOKEN>/setWebhook?url=https://your-bot.your-username.workers.dev/webhook
Replace <BOT_TOKEN>
with your actual bot token and update the Worker URL accordingly.
You should see a response like:
{"ok":true,"result":true,"description":"Webhook was set"}
MIT