diff options
| author | Dhravya <[email protected]> | 2024-06-23 17:24:10 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-23 17:24:10 -0500 |
| commit | 9df975e88f3ebbed5a9f064b98e67c91f21cd39a (patch) | |
| tree | 8e813ec001ce2bc5c4a61c8bfa79e73ef1615dc1 /apps/web/app/api | |
| parent | Merge pull request #79 from Dhravya/chathistory (diff) | |
| download | supermemory-9df975e88f3ebbed5a9f064b98e67c91f21cd39a.tar.xz supermemory-9df975e88f3ebbed5a9f064b98e67c91f21cd39a.zip | |
added indexes and stuff
Diffstat (limited to 'apps/web/app/api')
| -rw-r--r-- | apps/web/app/api/telegram/route.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/web/app/api/telegram/route.ts b/apps/web/app/api/telegram/route.ts new file mode 100644 index 00000000..b80f6173 --- /dev/null +++ b/apps/web/app/api/telegram/route.ts @@ -0,0 +1,28 @@ +import { Bot, webhookCallback } from "grammy"; +import { User } from "grammy/types"; + +export const runtime = "edge"; + +if (!process.env.TELEGRAM_BOT_TOKEN) { + throw new Error("TELEGRAM_BOT_TOKEN is not defined"); +} + +console.log("Telegram bot activated"); +const token = process.env.TELEGRAM_BOT_TOKEN; + +const bot = new Bot(token); + +bot.command("start", async (ctx) => { + const user: User = (await ctx.getAuthor()).user; + await ctx.reply( + `Welcome to Supermemory bot, ${user.first_name}. I am here to help you remember things better.`, + ); +}); + +bot.on("message", async (ctx) => { + await ctx.reply( + "Hi there! This is Supermemory bot. I am here to help you remember things better.", + ); +}); + +export const POST = webhookCallback(bot, "std/http"); |