HowTo send TemplateMessages? #173
Replies: 8 comments 8 replies
-
|
Beta Was this translation helpful? Give feedback.
-
@Romerito007 I'm not talking about this message, but about this #176 |
Beta Was this translation helpful? Give feedback.
-
Template only on official API
Pada tanggal Sel, 21 Jun 2022 18.50, Denis Didenko ***@***.***>
menulis:
… @Romerito007 <https://github.com/Romerito007> I'm not talking about this
message, but about this #176
<#176>
—
Reply to this email directly, view it on GitHub
<#173 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALJQY2BOV2423RRWZAONILDVQGT7ZANCNFSM5ZI6MDUQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@hrizal It works in Baileys so it should work here too, or not? |
Beta Was this translation helpful? Give feedback.
-
Below is my code: package responces
import (
"DigitalAssistance/global"
"go.mau.fi/whatsmeow"
waProto "go.mau.fi/whatsmeow/binary/proto"
"google.golang.org/protobuf/proto"
"context"
"fmt"
"io/ioutil"
)
func Bye(sender string) {
content, err := ioutil.ReadFile("./documents/Eid.png")
if err != nil {
fmt.Println(err)
}
resp, err := global.Cli.Upload(context.Background(), content, whatsmeow.MediaImage)
if err != nil {
fmt.Println(err)
}
hydratedUrlButton := waProto.HydratedTemplateButton_UrlButton{
UrlButton: &waProto.HydratedURLButton{
DisplayText: proto.String("زر الرابط"),
Url: proto.String("https://www.bankaljazira.com/FFL"),
},
}
hydratedCallButton := waProto.HydratedTemplateButton_CallButton{
CallButton: &waProto.HydratedCallButton{
DisplayText: proto.String("Call me"),
PhoneNumber: proto.String("+1 23456789"),
},
}
hydratedQuickReplyButton := waProto.HydratedTemplateButton_QuickReplyButton{
QuickReplyButton: &waProto.HydratedQuickReplyButton{
DisplayText: proto.String("Quick Reply 1"),
Id: proto.String("QuickReply1"),
},
}
/*
imageMessage := waProto.ImageMessage{
Url: proto.String("https://mmg.whatsapp.net/d/f/AlAF9hFHR7336ScKIqHneB2NpVYsiKWsT05RKTdEUSbl.enc "),
Mimetype: proto.String("image/jpeg"),
Caption: proto.String("الآن بطاقة العملات مجاناً مدى الحياة تقدّم بالحصول عليها من خلال القنوات الالكترونية لبنك الجزيرة أو عبر الفرع"),
}
*/
imageMessage := waProto.ImageMessage{
// Caption: proto.String("شكرا و عيدكم مبارك"),
Mimetype: proto.String("image/png"), // replace this with the actual mime type
// you can also optionally add other fields like ContextInfo and JpegThumbnail here
Url: &resp.URL,
DirectPath: &resp.DirectPath,
MediaKey: resp.MediaKey,
FileEncSha256: resp.FileEncSHA256,
FileSha256: resp.FileSHA256,
FileLength: &resp.FileLength,
}
hydratedImage := waProto.HydratedFourRowTemplate_ImageMessage{
ImageMessage: &imageMessage,
}
hydratedFourRowTemplate := waProto.HydratedFourRowTemplate{
// HydratedContentText: proto.String("الآن العرض الجديد"),
// HydratedFooterText: proto.String("تطبّق الشروط والأحكام"),
HydratedButtons: []*waProto.HydratedTemplateButton{
{
Index: proto.Uint32(uint32(1)),
HydratedButton: &hydratedUrlButton,
},
{
Index: proto.Uint32(uint32(2)),
HydratedButton: &hydratedCallButton,
},
{
Index: proto.Uint32(uint32(3)),
HydratedButton: &hydratedQuickReplyButton,
},
},
TemplateId: proto.String("id1"),
Title: &hydratedImage,
}
templateMessage := waProto.TemplateMessage{
// ContextInfo: &waProto.ContextInfo{},
HydratedTemplate: &hydratedFourRowTemplate,
Format: nil,
}
msg := waProto.Message{
// Conversation: proto.String("Hello"),
TemplateMessage: &templateMessage,
}
jid, ok := global.ParseJID(sender)
if !ok {
return
}
send, err := global.Cli.SendMessage(jid, "", &msg) // jid = recipient
if err != nil {
global.Log.Errorf("Error sending message: %v", err)
} else {
global.Log.Infof("Message sent (server timestamp: %s)", send)
}
} It worked fine with me at WhatsApp desktop app: But no idea why it is not appearing at my WhatsApp mobile app, both personal and business accounts! |
Beta Was this translation helpful? Give feedback.
-
Please how do i set a custom message that replies every single message i receive in my dm |
Beta Was this translation helpful? Give feedback.
-
How do i create a suggestion interface where by if a user types in something like "/", a list of suggestions would come out from the input. |
Beta Was this translation helpful? Give feedback.
-
Hi!
Tell me how to send a TemplateMessage with buttons, like here: https://github.com/adiwajshing/Baileys/issues/1424#issuecomment-1080454467
I would be grateful for a code example.
Beta Was this translation helpful? Give feedback.
All reactions