Skip to content

Commit 4cb08cb

Browse files
committed
Auto set Telegram webhook on create
1 parent bc74b6f commit 4cb08cb

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎apps/admin-web/src/ui/panels/PlatformsPanel.tsx‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,28 @@ export function PlatformsPanel({ client, notify }: PanelProps) {
3333

3434
async function createIntegration() {
3535
try {
36-
await client.createTelegramIntegration({
36+
const created = await client.createTelegramIntegration({
3737
agentId: draft.agentId || undefined,
3838
name: draft.name,
3939
botToken: draft.botToken || undefined,
4040
webhookSecret: draft.webhookSecret || undefined
4141
});
42+
if (draft.botToken) {
43+
const webhook = await client.setTelegramWebhook(
44+
created.integration.id,
45+
webhookUrl
46+
);
47+
setResult(webhook);
48+
} else {
49+
setResult(created);
50+
}
4251
setDraft({ ...draft, botToken: "", webhookSecret: "" });
43-
notify("Telegram integration saved", "ok");
52+
notify(
53+
draft.botToken
54+
? "Telegram integration saved and webhook set"
55+
: "Telegram integration saved",
56+
"ok"
57+
);
4458
await load();
4559
} catch (error) {
4660
notify(error instanceof Error ? error.message : "Failed to save Telegram", "error");

0 commit comments

Comments
 (0)