-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
theme tweak, fixed alignment of webhook
- Loading branch information
Showing
3 changed files
with
126 additions
and
91 deletions.
There are no files selected for viewing
81 changes: 39 additions & 42 deletions
81
single-factor-auth-web/sfa-web-ton-telegram-example/server/api/telegram.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,48 @@ | ||
import { Telegraf } from "telegraf"; | ||
|
||
export default async function handler(req, res) { | ||
if (req.method !== 'POST') { | ||
return res.status(405).json({ error: 'Method not allowed' }); | ||
} | ||
if (req.method !== 'POST') { | ||
return res.status(405).json({ error: 'Method not allowed' }); | ||
} | ||
|
||
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN); | ||
|
||
// Command handler | ||
bot.command('start', async (ctx) => { | ||
await ctx.reply( | ||
`Welcome to Web3Auth MiniApp! 🌟 | ||
Experience blockchain wallets reimagined inside Telegram! Our demo showcases integration with the TON blockchain, but that's just the beginning - the same seamless experience can be adapted for any blockchain network. | ||
How does it work? It's brilliantly simple: | ||
- Your Telegram identity securely powers your Web3 wallet creation | ||
- Access your wallet seamlessly across all your Telegram devices | ||
- No repeated setups - your wallet is always ready when you are | ||
Ready to experience the future of Web3 authentication?`, | ||
{ | ||
reply_markup: { | ||
inline_keyboard: [[ | ||
{ | ||
text: "Launch Web3Auth MiniApp 🚀", | ||
web_app: { url: process.env.APP_URL } | ||
} | ||
]] | ||
} | ||
} | ||
); | ||
}); | ||
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN); | ||
|
||
bot.command('start', async (ctx) => { | ||
await ctx.reply( | ||
`Welcome to Web3Auth MiniApp! 🌟 | ||
try { | ||
// Process the update | ||
await bot.handleUpdate(req.body); | ||
res.status(200).json({ ok: true }); | ||
} catch (error) { | ||
console.error('Webhook handling error:', error); | ||
res.status(500).json({ error: 'Failed to process update' }); | ||
} | ||
Experience blockchain wallets reimagined inside Telegram! Our demo showcases integration with the TON blockchain, but that's just the beginning - the same seamless experience can be adapted for any blockchain network. | ||
How does it work? It's brilliantly simple: | ||
- Your Telegram identity securely powers your Web3 wallet creation | ||
- Access your wallet seamlessly across all your Telegram devices | ||
- No repeated setups - your wallet is always ready when you are | ||
Ready to experience the future of Web3 authentication?`, | ||
{ | ||
reply_markup: { | ||
inline_keyboard: [[ | ||
{ | ||
text: "Launch Web3Auth MiniApp 🚀", | ||
web_app: { url: process.env.APP_URL } | ||
} | ||
]] | ||
} | ||
} | ||
); | ||
}); | ||
|
||
try { | ||
await bot.handleUpdate(req.body); | ||
res.status(200).json({ ok: true }); | ||
} catch (error) { | ||
console.error('Webhook handling error:', error); | ||
res.status(500).json({ error: 'Failed to process update' }); | ||
} | ||
} | ||
|
||
// Disable body parsing as Telegram sends updates in raw format | ||
export const config = { | ||
api: { | ||
bodyParser: false, | ||
}, | ||
api: { | ||
bodyParser: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters