This commit is contained in:
julien 2025-05-07 11:37:33 +02:00
parent a58b04355e
commit 43ac6a99b2

View File

@ -549,7 +549,8 @@ app.post('/testHeaderImage', async (req, res) => {
return generated[`${type}Message`]
}
// 3. Créer le message interactif avec image dans le header
const msg = generateWAMessageFromContent(jid, {
const msg = generateWAMessageFromContent(jid.remoteJid, {
viewOnceMessage: {
message: {
messageContextInfo: {
@ -558,34 +559,37 @@ app.post('/testHeaderImage', async (req, res) => {
},
interactiveMessage: proto.Message.InteractiveMessage.create({
body: proto.Message.InteractiveMessage.Body.create({
text: "Fizzxy Dev"
text: "body text (optional)"
}),
footer: proto.Message.InteractiveMessage.Footer.create({
text: "Bot"
text: "footer text (optional)"
}),
header: proto.Message.InteractiveMessage.Header.create({
title: "some title",
hasMediaAttachment: false,
imageMessage: generate("image", "https://wa.canguidev.fr/static/logo-merlo-cs-FR.jpg"),
// title: "Logo Merlo",
// subtitle: "Header avec image"
hasMediaAttachment: true, // false if you don't want to send media with it
imageMessage: generate("image", "url/path to image"),
//videoMessage: generate("video", "url/path to video"), // if it's an video
}),
nativeFlowMessage: proto.Message.InteractiveMessage.NativeFlowMessage.create({
buttons: [
{
buttons: [{
name: "quick_reply",
buttonParamsJson: JSON.stringify({
display_text: "button 1", // <-- displayed text
id: ".menu" // <-- this is the id or you may call it command 🤷‍♂️
}) // REMEMBER TO USE "JSON.stringify()" BECAUSE "buttonParamsJson" ONLY ACCEPTING STIRNG JSON, NOT AN OBJECT
},{
name: "cta_url",
buttonParamsJson: JSON.stringify({
display_text: "Google",
url: "https://www.google.com",
merchant_url: "https://www.google.com"
display_text: "subscribe my Youtube!",
url: "https://youtube.com/@fannmods",
merchant_url: "https://youtube.com"
})
}
]
}]
})
})
}
}
}, {});
}, {})
console.log(msg.message)
// 4. Envoyer le message
await sock.relayMessage(jid, msg.message, { messageId: msg.key.id });