dssfesfz
This commit is contained in:
parent
f336c9eaa5
commit
432c43c0d7
44
index.js
44
index.js
@ -126,25 +126,35 @@ app.post('/sendButtons', async (req, res) => {
|
|||||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const msg = {
|
const msgContent = {
|
||||||
text: 'Choisis une option :',
|
buttonsMessage: {
|
||||||
footer: 'Clique sur un bouton ci-dessous',
|
contentText: 'Choisis une option :',
|
||||||
buttons: [
|
footerText: 'Clique sur un bouton ci-dessous',
|
||||||
{
|
buttons: [
|
||||||
buttonId: 'id_produits',
|
{
|
||||||
buttonText: { displayText: '🛍 Voir produits' },
|
buttonId: 'id_produits',
|
||||||
type: 1
|
buttonText: { displayText: '🛍 Voir produits' },
|
||||||
},
|
type: 1
|
||||||
{
|
},
|
||||||
buttonId: 'id_support',
|
{
|
||||||
buttonText: { displayText: '☎ Contacter support' },
|
buttonId: 'id_support',
|
||||||
type: 1
|
buttonText: { displayText: '☎ Contacter support' },
|
||||||
}
|
type: 1
|
||||||
],
|
}
|
||||||
headerType: 1
|
],
|
||||||
|
headerType: 1
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await sock.sendMessage(`${phone}@s.whatsapp.net`, msg);
|
const msg = generateWAMessageFromContent(
|
||||||
|
`${phone}@s.whatsapp.net`,
|
||||||
|
{ buttonsMessage: msgContent.buttonsMessage },
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('✅ Message généré :', JSON.stringify(msg.message, null, 2));
|
||||||
|
|
||||||
|
await sock.relayMessage(`${phone}@s.whatsapp.net`, msg.message, { messageId: msg.key.id });
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('❌ Erreur bouton simple :', e);
|
console.error('❌ Erreur bouton simple :', e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user