Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto buttons and special dialogs #96

Closed
hajsf opened this issue Apr 20, 2022 · 4 comments
Closed

Auto buttons and special dialogs #96

hajsf opened this issue Apr 20, 2022 · 4 comments

Comments

@hajsf
Copy link

hajsf commented Apr 20, 2022

Hi,
Not sure if the title is clear or misleading, but here what I'm looking for, that I got wile contacting some WhatsApp business account:

  1. First requirement is getting auto reply buttons at the end of the message, so that the user click one of them.
  2. Second requirement is getting a custom dialog opened with some options for the user to select from

Is there something like this at Whatsmeow package? Thanks

image

@hrizal
Copy link

hrizal commented Apr 20, 2022

number 1 is possible
number 2 not sure

@hajsf
Copy link
Author

hajsf commented Apr 20, 2022

number 1 is possible

How, and what is the correct making if it?

@ander890
Copy link

yes you can, first one is button message, second is list message. you should explore more bcs this library has very few examples haha

for button message
read this documentation

and you can implement like

msg := &waProto.Message{ButtonsMessage: &waProto.ButtonsMessage{
	HeaderType:  waProto.ButtonsMessage_EMPTY.Enum(),
	ContentText: proto.String("text"),
	FooterText:  proto.String("footer"),
	Buttons: []*waProto.Button{
		{
			ButtonId: proto.String("id1"),
			ButtonText: &waProto.ButtonText{
				DisplayText: proto.String("button Text"),
			},
			Type: waProto.Button_RESPONSE.Enum(),
		},
	},
}}

send, err := cli.SendMessage(jid, "", msg)

@hajsf
Copy link
Author

hajsf commented Apr 21, 2022

Thanks @ander890
Now it is working with me as:

  1. Button Message:
	msg := &waProto.Message{
		ListResponseMessage: &waProto.ListResponseMessage{
			Title:       proto.String("title"),
			Description: proto.String("Description"),
			SingleSelectReply: &waProto.SingleSelectReply{
				SelectedRowId: proto.String("SelectedRowId1"),
			},
			//	ContextInfo: ,
			ListType: waProto.ListResponseMessage_SINGLE_SELECT.Enum(),
		},
	}
  1. List Message:
	msg := &waProto.Message{
		ListMessage: &waProto.ListMessage{
			Title:       proto.String("ListMessage title"),
			Description: proto.String("ListMessage Description"),
			FooterText:  proto.String("ListMessage footer"),
			ButtonText:  proto.String("ListMessage ButtonText"),
			ListType:    waProto.ListMessage_SINGLE_SELECT.Enum(),
			Sections: []*waProto.Section{
				{
					Title: proto.String("Section1 title"),
					Rows: []*waProto.Row{
						{
							RowId:       proto.String("id1"),
							Title:       proto.String("ListMessage section row title"),
							Description: proto.String("ListMessage section row desc"),
						},
						{
							RowId:       proto.String("id2"),
							Title:       proto.String("title 2"),
							Description: proto.String("desc 2"),
						},
					},
				},
				{
					Title: proto.String("Section2 title"),
					Rows: []*waProto.Row{
						{
							RowId:       proto.String("id1"),
							Title:       proto.String("ListMessage section row title"),
							Description: proto.String("ListMessage section row desc"),
						},
						{
							RowId:       proto.String("id2"),
							Title:       proto.String("title 2"),
							Description: proto.String("desc 2"),
						},
					},
				},
			},
		},
	}

Then sending it as:

	jid, ok := parseJID("966xxxxx")
	if !ok {
		return
	}
	send, err := cli.SendMessage(jid, "", msg) // jid = recipient

	if err != nil {
		log.Errorf("Error sending message: %v", err)
	} else {
		log.Infof("Message sent (server timestamp: %s)", send)
	}

@hajsf hajsf closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants