aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/api
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-06-23 17:24:10 -0500
committerDhravya <[email protected]>2024-06-23 17:24:10 -0500
commit9df975e88f3ebbed5a9f064b98e67c91f21cd39a (patch)
tree8e813ec001ce2bc5c4a61c8bfa79e73ef1615dc1 /apps/web/app/api
parentMerge pull request #79 from Dhravya/chathistory (diff)
downloadsupermemory-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.ts28
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");