@qadeerxtech/qadeer-btns
v1.0.2
Published
Advanced Baileys interactive buttons wrapper by Team Qadeer
Maintainers
Readme
📌 Problem Statement
By default, the @whiskeysockets/baileys library lacks the required binary wrappers (biz, interactive, native_flow) that WhatsApp needs to display interactive buttons. Qadeer-Btns solves this by automatically formatting your buttons and injecting the missing binary nodes seamlessly.
🚀 Key Features
- ✅ No core edits required in your Baileys folders.
- ✅ Auto Node Injection (
biz,interactive,native_flow). - ✅ Full Button Support: Quick Replies, URL CTAs, Copy CTAs, Call CTAs, Lists, and Location sharing.
- ✅ Media Support: Add images to your button headers (via URL, buffer, or local path).
- ✅ AI Mode (
aimode): Auto-injects thebotnode (biz_bot: '1') for advanced conversational AI flows in private chats. - ✅ Cross-Chat Support: Works flawlessly in both Private (1:1) and Group chats.
🛠️ Installation
You can install this scoped package using npm, yarn, or bun:
npm install @qadeerxtech/qadeer-btnsNote: Make sure your Baileys version is 7.0.0-rc.2+ and Node.js is 20+.
💻 Usage & Examples
First, require the library in your code:
const { sendButtons, sendInteractiveMessage } = require('@qadeerxtech/qadeer-btns');1. Basic Quick Replies (The Simple Way)
If you just want to send simple text buttons, qadeer-btns auto-converts basic {id, text} objects into the proper WhatsApp format.
await sendButtons(sock, m.chat, {
title: '👋 Welcome to Team Qadeer',
text: 'Please select an option below:',
footer: 'Powered by Qadeer-Btns',
image: { url: 'https://example.com/menu-image.jpg' }, // Optional Image
aimode: true, // Enables AI node for private chats
buttons: [
{ id: 'btn_ping', text: 'Ping 🏓' },
{ id: 'btn_menu', text: 'View Menu 📜' }
]
});2. Advanced Multi-Type Buttons (URL, Copy, Call)
You can mix different types of Call-To-Action (CTA) buttons in a single message using sendInteractiveMessage.
Note: You must stringify the payload inside buttonParamsJson.
await sendInteractiveMessage(sock, m.chat, {
text: 'Here are some advanced actions:',
footer: 'Team Qadeer Tools',
interactiveButtons: [
// 1. URL Button
{
name: 'cta_url',
buttonParamsJson: JSON.stringify({
display_text: 'Visit Our Website 🌐',
url: 'https://qadeerxtech.com'
})
},
// 2. Copy Code Button
{
name: 'cta_copy',
buttonParamsJson: JSON.stringify({
display_text: 'Copy Owner Number 📋',
copy_code: '+923000000000'
})
},
// 3. Tap to Call Button
{
name: 'cta_call',
buttonParamsJson: JSON.stringify({
display_text: 'Call Support 📞',
phone_number: '+923000000000'
})
}
]
});3. Single Select Lists (Menus)
Want to show a categorized drop-down menu? Use the single_select flow.
await sendInteractiveMessage(sock, m.chat, {
text: 'Explore our commands below:',
footer: 'Interactive List Menu',
interactiveButtons: [
{
name: 'single_select',
buttonParamsJson: JSON.stringify({
title: 'Tap to Open Menu 📂',
sections: [
{
title: '🛠️ Utility Commands',
rows: [
{ header: '', title: 'Ping', description: 'Check bot latency', id: 'cmd_ping' },
{ header: '', title: 'Runtime', description: 'Check bot uptime', id: 'cmd_runtime' }
]
},
{
title: '🎉 Fun Commands',
rows: [
{ header: '', title: 'Joke', description: 'Get a random joke', id: 'cmd_joke' },
{ header: '', title: 'Meme', description: 'Get a random meme', id: 'cmd_meme' }
]
}
]
})
}
]
});4. Send Location Button (Experimental)
Request the user to share their location easily.
await sendInteractiveMessage(sock, m.chat, {
text: 'Please share your location for delivery:',
interactiveButtons: [
{
name: 'send_location',
buttonParamsJson: JSON.stringify({
display_text: 'Share Location 📍'
})
}
]
});🧠 Creating a Helper Function in Your Bot
To keep your bot code clean, you can create a helper function (e.g., lib/kiara_btns.js) just like KIARA MD MINI:
const { sendInteractiveMessage } = require('@qadeerxtech/qadeer-btns');
async function sendKiaraBtns(sock, m, options = {}) {
const interactiveButtons = options.buttons.map(btn => {
switch (btn.type) {
case 'url':
return { name: 'cta_url', buttonParamsJson: JSON.stringify({ display_text: btn.display_text, url: btn.url }) };
case 'copy':
return { name: 'cta_copy', buttonParamsJson: JSON.stringify({ display_text: btn.display_text, copy_code: btn.copy_code }) };
case 'call':
return { name: 'cta_call', buttonParamsJson: JSON.stringify({ display_text: btn.display_text, phone_number: btn.phone_number }) };
case 'list':
return { name: 'single_select', buttonParamsJson: JSON.stringify({ title: btn.title, sections: btn.sections }) };
default: // Default is quick_reply
return { name: 'quick_reply', buttonParamsJson: JSON.stringify({ display_text: btn.display_text, id: btn.id }) };
}
});
let msgOptions = {
text: options.text,
footer: options.footer || 'POWERED BY TEAM QADEER',
interactiveButtons: interactiveButtons
};
if (options.image) msgOptions.image = { url: options.image };
await sendInteractiveMessage(sock, m.chat, msgOptions, { quoted: m });
}
module.exports = { sendKiaraBtns };🤝 Need Help?
If you find any bugs or have feature requests, feel free to reach out to Team Qadeer!
