From 14ff2aecb8f0d29b7a9505f5e92b0bc99fffbc6a Mon Sep 17 00:00:00 2001 From: Ahmed Aboelyazeed Date: Sun, 14 Apr 2019 12:28:09 +0200 Subject: [PATCH] add list template --- response.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/response.go b/response.go index d1012a8..4ee192d 100644 --- a/response.go +++ b/response.go @@ -285,6 +285,32 @@ func (r *Response) GenericTemplate(elements *[]StructuredMessageElement, messagi return r.DispatchMessage(&m) } +// ListTemplate sends a list of elements +func (r *Response) ListTemplate(elements *[]StructuredMessageElement, messagingType MessagingType, tags ...string) error { + var tag string + if len(tags) > 0 { + tag = tags[0] + } + + m := SendStructuredMessage{ + MessagingType: messagingType, + Recipient: r.to, + Message: StructuredMessageData{ + Attachment: StructuredMessageAttachment{ + Type: "template", + Payload: StructuredMessagePayload{ + TopElementStyle: "compact", + TemplateType: "list", + Buttons: nil, + Elements: elements, + }, + }, + }, + Tag: tag, + } + return r.DispatchMessage(&m) +} + // SenderAction sends a info about sender action func (r *Response) SenderAction(action string) error { m := SendSenderAction{