JJJJJJ
This commit is contained in:
parent
3b248cc943
commit
d2353f9b5b
88
index.js
88
index.js
@ -70,52 +70,53 @@ app.post('/sendText', async (req, res) => {
|
||||
|
||||
app.post('/sendButtons', async (req, res) => {
|
||||
const { phone } = req.body;
|
||||
if (!sock || !isConnected) return res.status(400).json({ error: 'Non connecté' });
|
||||
|
||||
if (!client || !isConnected) {
|
||||
return res.status(400).json({ error: 'Non connecté' });
|
||||
}
|
||||
|
||||
const BASE_URL = process.env.BASE_URL || 'https://wa.canguidev.fr';
|
||||
const imageUrl = `${BASE_URL}/static/logo-merlo-cs-FR.jpg`;
|
||||
try {
|
||||
const content = {
|
||||
message: {
|
||||
interactiveMessage: proto.Message.InteractiveMessage.create({
|
||||
image: { url : imageUrl }, // Can buffer
|
||||
body: { text: "Bienvenue sur notre service !" },
|
||||
footer: { text: "Choisis une action ci-dessous" },
|
||||
header: {
|
||||
title: "Menu principal",
|
||||
hasMediaAttachment: false
|
||||
},
|
||||
nativeFlowMessage: {
|
||||
buttons: [
|
||||
{
|
||||
name: "cta_reply",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "📩 Contacter support",
|
||||
id: "support_action"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_url",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "🌐 Voir notre site",
|
||||
url: "https://canguidev.fr",
|
||||
merchant_url: "https://canguidev.fr"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_call",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "📞 Appeler le support",
|
||||
id: "+33612345678"
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
const jid = `${phone}@s.whatsapp.net`;
|
||||
|
||||
const msg = generateWAMessageFromContent(`${phone}@s.whatsapp.net`, content, {});
|
||||
await sock.relayMessage(`${phone}@s.whatsapp.net`, msg.message, { messageId: msg.key.id });
|
||||
try {
|
||||
await client.sendMessage(
|
||||
jid,
|
||||
{
|
||||
image: { url: imageUrl },
|
||||
caption: "Bienvenue sur notre service !",
|
||||
title: "Menu principal",
|
||||
subtitle: "Choisis une action ci-dessous",
|
||||
footer: "MERLO FRANCE",
|
||||
media: true,
|
||||
interactiveButtons: [
|
||||
{
|
||||
name: "quick_reply",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "📩 Contacter support",
|
||||
id: "support_action"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_url",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "🌐 Voir notre site",
|
||||
url: "https://canguidev.fr"
|
||||
})
|
||||
},
|
||||
{
|
||||
name: "cta_call",
|
||||
buttonParamsJson: JSON.stringify({
|
||||
display_text: "📞 Appeler le support",
|
||||
id: "+33612345678"
|
||||
})
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
quoted: null // tu peux remplacer `null` par un message existant si besoin
|
||||
}
|
||||
);
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (e) {
|
||||
@ -123,6 +124,7 @@ app.post('/sendButtons', async (req, res) => {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Votre route POST
|
||||
app.post('/sendInteractiveImage', async (req, res) => {
|
||||
const { phone, caption, title, subtitle, footer } = req.body;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user