fix: send telegram confirmation messages during business connect flow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { getHeader, readBody } from "h3";
|
||||
import { prisma } from "../../../../utils/prisma";
|
||||
import { telegramBotApi } from "../../../../utils/telegram";
|
||||
import {
|
||||
extractLinkTokenFromStartText,
|
||||
getBusinessConnectionFromUpdate,
|
||||
@@ -61,6 +62,13 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
});
|
||||
|
||||
if (chatId) {
|
||||
void telegramBotApi("sendMessage", {
|
||||
chat_id: chatId,
|
||||
text: "CRM: связка аккаунта получена. Теперь подключите Telegram Business в настройках Telegram, затем вернитесь в CRM и обновите статус.",
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
return { ok: true, accepted: true, type: "start_link" };
|
||||
}
|
||||
|
||||
@@ -123,6 +131,13 @@ export default defineEventHandler(async (event) => {
|
||||
prisma.telegramBusinessConnection.delete({ where: { id: matchedPending.id } }),
|
||||
]);
|
||||
|
||||
if (businessConnection.userChatId) {
|
||||
void telegramBotApi("sendMessage", {
|
||||
chat_id: businessConnection.userChatId,
|
||||
text: "CRM: Telegram Business подключен. Теперь входящие сообщения будут появляться в CRM.",
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
return { ok: true, accepted: true, type: "business_connection" };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user