@nexuo/core
v1.0.0
Published
WhatsApp button helper for Baileys - Mudah kirim button, list, dan interactive message
Maintainers
Readme
::: {align="center"}
@nexuo/core
Lightweight helper for WhatsApp interactive messages using Baileys.
Built to keep your bot code clean, minimal, and consistent. :::
Overview
Writing interactive WhatsApp messages with Baileys can be repetitive and messy.
@nexuo/core extends the Baileys socket with a convenient sendButton
method and automatic button response parsing, helping you reduce
boilerplate and standardize your bot handler.
Features
- Multiple button types (quick reply, URL, copy code, phone)\
- Interactive list menu support\
- Built-in external ad reply support\
- Automatic mention parsing\
- Full
contextInfocontrol\ - Response normalization into
m.text
Requirements
Dependency Version
Node.js >= 20 Baileys ^7.0.0-rc.9
Installation
npm install @nexuo/coreQuick Start
Initialization
const { ButtonCreate } = require('@nexuo/core')
const makeWASocket = require('baileys')
const client = makeWASocket({})
ButtonCreate(client)Handling Button Responses
Place ButtonResponse after smsg and before your main handler.
const { ButtonResponse } = require('@nexuo/core')
sock.ev.on('messages.upsert', async (chatUpdate) => {
const mek = chatUpdate.messages[0]
if (!mek.message) return
const m = smsg(client, mek, {})
ButtonResponse(m)
require('./XEoms')(client, m, chatUpdate)
})All button and list replies will automatically normalize into m.text.
Usage Examples
Basic Menu
client.sendButton(m.chat, {
text: 'Please choose a menu below',
footer: 'Bot Menu',
buttons: [
{ buttonName: 'Main Menu', id: 'menu' },
{ buttonName: 'Owner', id: 'owner' },
{ buttonName: 'Website', url: 'https://example.com' }
]
})Information Message
client.sendButton(m.chat, {
title: 'BOT INFORMATION',
subtitle: 'System Update',
text: 'The bot is running normally and ready to use.',
footer: 'Bot Notification',
buttons: [
{ buttonName: 'Check Status', id: 'status' }
]
}, { quoted: m })With Mention
client.sendButton(m.chat, {
text: `Hello @${m.sender.split('@')[0]}, select the feature you want to use.`,
footer: 'Main Menu',
buttons: [
{ buttonName: 'Profile', id: 'profile' }
],
mentions: [m.sender]
}, { quoted: m })Promotional Message
client.sendButton(m.chat, {
text: 'Special promotion available this week.',
footer: 'Limited Offer',
buttons: [
{ buttonName: 'Order Now', url: 'https://shop.com' }
],
contextInfo: {
externalAdReply: {
title: 'WEEKLY PROMO',
body: 'Limited time discount',
thumbnailUrl: 'https://example.com/image.jpg',
sourceUrl: 'https://example.com',
mediaType: 1,
renderLargerThumbnail: true
}
}
}, { quoted: m })Category List Menu
client.sendButton(m.chat, {
text: 'Select a category below',
buttons: [
{
buttonName: 'Food Menu',
title: 'Food Category',
rows: [
{ title: 'Main Course', description: 'Rice, noodles, etc.', id: 'main_course' }
]
},
{
buttonName: 'Drink Menu',
title: 'Drink Category',
rows: [
{ title: 'Hot Drinks', description: 'Coffee, tea', id: 'hot_drinks' }
]
}
]
}, { quoted: m })API Reference
ButtonCreate(client, options)
Parameter Type Required Description
client object Yes Baileys socket instance options object No Custom configuration
ButtonResponse(message)
Parameter Type Required Description
message object Yes Baileys message object
client.sendButton(jid, content, options)
Parameter Type Required Description
jid string Yes Target chat ID content object | string Yes Message content options object No Additional Baileys options
License
MIT
Contributing
Contributions are welcome.
Please open an issue or submit a pull request.
