Add balance to user account 💸
📁 Filename:
addBal.js👨💻 Code:
const ADMIN_ID = process.env.ADMIN_ID;
if (flex.user.id != ADMIN_ID) return;
await sendMessage("*Enter your user id 🆔*", "MARKDOWN");
await waitForAnswer("/getId");
📁 Filename:
getId.js👨💻 Code:
const ADMIN_ID = process.env.ADMIN_ID;
if (flex.user.id != ADMIN_ID) return;
await USER.setProperty("id", flex.message);
await sendMessage("*Enter your balance 💸*", "MARKDOWN");
await waitForAnswer("/getBal");
📁 Filename:
getBal.js👨💻 Code:
const ADMIN_ID = process.env.ADMIN_ID;
const id = await USER.getProperty("id");
const btn = [
[
{
text: "Claim Reward 🎉",
callback_data: /claimBal ${id} ${flex.message} ,
},
],
];
if (flex.user.id != ADMIN_ID) return;
await BOT.sendMessage(
id,
"*🎉 Congratulation you have get points from admin*\n\nClick following button to claim reward!!",
"MARKDOWN",
btn,
);
await sendMessage(*Point add request sended to *${id} ✅, "MARKDOWN");
await USER.deleteProperty("id");
await clearWait();
📁 Filename:
claimBal.js👨💻 Code:
const parts = flex.params.split(" ");
const id = parts[0];
const amount = parseFloat(parts[1]);
if (flex.user.id != id) return;
if (!isCallback) return;
await FLEX.setProperty("balance", amount);
await answerCallback("Balance added successfully ✅", true);⚠️ Note: add your user id in .env file like ADMIN_ID=1234567890#FlexGram
👍3❤2👌2
🌟 Automating client feedback loops on autopilot
Clients rarely fill out feedback forms emailed to them, but they'll tap a button in Telegram in two seconds. I built this lightweight flow to capture star ratings and text reviews directly inside our support chat. It stores the rating in memory, shifts the user context to wait for their text comments, and then commits everything to their persistent database profile in one seamless conversational experience.
📁 Filename:
👨💻 Code:
📁 Filename:
👨💻 Code:
📁 Filename:
👨💻 Code:
💡 Always remember to call
#FlexGram
Clients rarely fill out feedback forms emailed to them, but they'll tap a button in Telegram in two seconds. I built this lightweight flow to capture star ratings and text reviews directly inside our support chat. It stores the rating in memory, shifts the user context to wait for their text comments, and then commits everything to their persistent database profile in one seamless conversational experience.
📁 Filename:
command/feedback.js👨💻 Code:
sendMessage("How would you rate our service today?", {
buttons: [
[
{ text: "⭐ 1", command: "/rate 1" },
{ text: "⭐ 2", command: "/rate 2" },
{ text: "⭐ 3", command: "/rate 3" },
{ text: "⭐ 4", command: "/rate 4" },
{ text: "⭐ 5", command: "/rate 5" }
]
]
})📁 Filename:
command/rate.js👨💻 Code:
TEMP.setProp("rating", params)
sendMessage("Awesome! Now, please type a short comment about your experience:")
waitForAnswer("save")📁 Filename:
command/save.js👨💻 Code:
const rating = await TEMP.getProp("rating").value()
USER.setProp("last_rating", rating)
USER.setProp("last_comment", message)
sendMessage("Thank you! Your feedback has been saved securely.")
clearWait()💡 Always remember to call
clearWait() at the end of your waiting sequence, or your user will remain locked inside that input handler forever.⚠️ Note: Make sure yourFIREBASE_URLandFIREBASE_SECRETenvironment variables are configured so the persistent feedback data is successfully saved to your database.
#FlexGram
👍2🐳2