Exemplos
Bot do Telegram
Um bot em Node.js que pede o número ao lead, envia o MB WAY e avisa no chat quando o lead paga. Usa reference para saber a que chat responder.
// npm install telegraf express
import crypto from "node:crypto";
import express from "express";
import { Telegraf } from "telegraf";
const HOTTY = "https://hotty.online/api/public/v1";
const bot = new Telegraf(process.env.TELEGRAM_TOKEN);
bot.hears(/^9\d{8}$/, async (ctx) => {
const res = await fetch(HOTTY + "/payments", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.HOTTY_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
method: "mb_way",
amount: 25,
lead_name: ctx.from.first_name,
phone: ctx.message.text,
reference: String(ctx.chat.id),
idempotency_key: crypto.randomUUID(),
}),
});
const { ok, message } = await res.json();
await ctx.reply(ok ? "Aprove o pagamento na app MB WAY (tem 4 minutos)." : message);
});
const app = express();
app.post("/hotty", express.raw({ type: "application/json" }), async (req, res) => {
// verifique a assinatura como em «Avisos de pagamento» antes de continuar
const { event, payment } = JSON.parse(req.body.toString("utf8"));
const chat = Number(payment.reference);
if (event === "payment.paid") await bot.telegram.sendMessage(chat, "Pagamento recebido, obrigado!");
if (event === "payment.failed") await bot.telegram.sendMessage(chat, "O MB WAY não foi aprovado. Envie o número de novo.");
res.sendStatus(200);
});
app.listen(3000);
bot.launch();Sem programar
Não quer programar? No painel do Hotty, em Meus bots, pode ligar um bot do Telegram ao Hotty e falar com os leads em Conversas.
Dúvidas sobre o acesso, a taxa ou os limites: fale com o admin do Hotty.

