Hydrated message appears at desktop browser, but not appearing at mobile device #178
-
I've the below code: package responces
import (
"DigitalAssistance/global"
waProto "go.mau.fi/whatsmeow/binary/proto"
"google.golang.org/protobuf/proto"
"fmt"
)
func Bye(sender string) {
var x uint32 = 1
msg := &waProto.Message{
Conversation: proto.String("Hello"),
TemplateMessage: &waProto.TemplateMessage{
ContextInfo: &waProto.ContextInfo{},
HydratedTemplate: &waProto.HydratedFourRowTemplate{
HydratedContentText: proto.String("Vist us at:"),
HydratedFooterText: proto.String("Google"),
HydratedButtons: []*waProto.HydratedTemplateButton{
{
Index: &x, //new(uint32),
HydratedButton: &waProto.HydratedTemplateButton_UrlButton{
UrlButton: &waProto.HydratedURLButton{
DisplayText: proto.String("Click here"),
Url: proto.String("https://www.google.com"),
},
},
},
},
TemplateId: nil, // new(string),
Title: nil,
},
Format: nil,
},
}
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)
}
} The message is sent as I can see at my desktop agent, but I can not see at at the WhatsApp mobile app neither at the sender device nor at the receiver: Note:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Below worked fine with me: package responces
import (
"DigitalAssistance/global"
"context"
"fmt"
"io/ioutil"
"go.mau.fi/whatsmeow"
waProto "go.mau.fi/whatsmeow/binary/proto"
"google.golang.org/protobuf/proto"
)
func Bye(sender string) {
content, err := ioutil.ReadFile("./documents/kottouf.png")
if err != nil {
fmt.Println(err)
}
resp, err := global.Cli.Upload(context.Background(), content, whatsmeow.MediaImage)
if err != nil {
fmt.Println(err)
}
// Creating template message
msg := waProto.Message{
TemplateMessage: &waProto.TemplateMessage{
HydratedTemplate: &waProto.HydratedFourRowTemplate{
Title: &waProto.HydratedFourRowTemplate_ImageMessage{
ImageMessage: &waProto.ImageMessage{
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,
Height: proto.Uint32(410),
Width: proto.Uint32(1200),
},
},
TemplateId: proto.String("template-id"),
HydratedContentText: proto.String("سيقوم قسم المشتريات بالتواصل معكم قريبا"),
HydratedFooterText: proto.String("لطلب منتجات من قطوف و حلا، يمكنكم زيارة السوق الإلكتروني أو التواصل هاتفيا"),
HydratedButtons: []*waProto.HydratedTemplateButton{
// This for URL button
{
Index: proto.Uint32(1),
HydratedButton: &waProto.HydratedTemplateButton_UrlButton{
UrlButton: &waProto.HydratedURLButton{
DisplayText: proto.String("للتسوق إضغط الزر"),
Url: proto.String("https://kottouf.co/"),
},
},
},
// This for call button
{
Index: proto.Uint32(2),
HydratedButton: &waProto.HydratedTemplateButton_CallButton{
CallButton: &waProto.HydratedCallButton{
DisplayText: proto.String("للطلبات إتصل على"),
PhoneNumber: proto.String("00966559528883"),
},
},
},
},
},
},
}
// Sending message
// WaClient.SendMessage(event.Info.Chat, "", this_message)
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)
}
} |
Beta Was this translation helpful? Give feedback.
-
Does you have "Disappearing" context issue ( i button) ? I'm also added to image message context info, but just same result. |
Beta Was this translation helpful? Give feedback.
Below worked fine with me: