aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/web/app/api/telegram/route.ts15
-rw-r--r--apps/web/cf-env.d.ts1
-rw-r--r--package.json1
3 files changed, 13 insertions, 4 deletions
diff --git a/apps/web/app/api/telegram/route.ts b/apps/web/app/api/telegram/route.ts
index 0a140b40..b80f6173 100644
--- a/apps/web/app/api/telegram/route.ts
+++ b/apps/web/app/api/telegram/route.ts
@@ -3,19 +3,26 @@ import { User } from "grammy/types";
export const runtime = "edge";
-const token = process.env.TELEGRAM_BOT_TOKEN ?? "";
+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.`);
+ 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."
+ "Hi there! This is Supermemory bot. I am here to help you remember things better.",
);
});
-export const POST = webhookCallback(bot, "std/http"); \ No newline at end of file
+export const POST = webhookCallback(bot, "std/http");
diff --git a/apps/web/cf-env.d.ts b/apps/web/cf-env.d.ts
index be5c991a..3072a528 100644
--- a/apps/web/cf-env.d.ts
+++ b/apps/web/cf-env.d.ts
@@ -11,6 +11,7 @@ declare global {
R2_BUCKET_NAME: string;
BACKEND_SECURITY_KEY: string;
BACKEND_BASE_URL: string;
+ TELEGRAM_BOT_TOKEN: string;
}
}
}
diff --git a/package.json b/package.json
index b6597fd7..4d4e7c07 100644
--- a/package.json
+++ b/package.json
@@ -71,6 +71,7 @@
"compromise": "^14.13.0",
"drizzle-orm": "^0.30.10",
"framer-motion": "^11.2.6",
+ "grammy": "^1.25.1",
"katex": "^0.16.10",
"lucide-react": "^0.379.0",
"next-app-theme": "^0.1.10",