aboutsummaryrefslogtreecommitdiff
path: root/apps/web/app/api/telegram/route.ts
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-06-23 17:09:34 -0500
committerDhravya <[email protected]>2024-06-23 17:09:34 -0500
commit7117885a27672561e3f16f30afc6c05dbad738a6 (patch)
tree57668642405c9c90f2e0466e949abc5065663aa3 /apps/web/app/api/telegram/route.ts
parentadd: telegram bot setup with grammy lib (diff)
downloadsupermemory-feat/telegram-api.tar.xz
supermemory-feat/telegram-api.zip
error out if there's no idfeat/telegram-api
Diffstat (limited to 'apps/web/app/api/telegram/route.ts')
-rw-r--r--apps/web/app/api/telegram/route.ts15
1 files changed, 11 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");