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

feat: add button component to wpp message #102

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flows/actions/send_wpp_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ func (a *SendWppMsgAction) Execute(run flows.FlowRun, step flows.Step, logModifi
channelRef = assets.NewChannelReference(dest.Channel.UUID(), dest.Channel.Name())
}

msg := flows.NewMsgWppOut(dest.URN.URN(), channelRef, a.InteractionType, a.HeaderType, evaluatedHeaderText, evaluatedText, evaluatedFooter, ctaMessage, listMessage, flowMessage, orderDetailsMessage, evaluatedAttachments, evaluatedReplyMessage, nil, a.Topic)
msg := flows.NewMsgWppOut(dest.URN.URN(), channelRef, a.InteractionType, a.HeaderType, evaluatedHeaderText, evaluatedText, evaluatedFooter, ctaMessage, listMessage, flowMessage, orderDetailsMessage, evaluatedAttachments, evaluatedReplyMessage, nil, nil, a.Topic)
logEvent(events.NewMsgWppCreated(msg))
}

// if we couldn't find a destination, create a msg without a URN or channel and it's up to the caller
// to handle that as they want
if len(destinations) == 0 {
msg := flows.NewMsgWppOut(urns.NilURN, nil, a.InteractionType, a.HeaderType, evaluatedHeaderText, evaluatedText, evaluatedFooter, ctaMessage, listMessage, flowMessage, orderDetailsMessage, evaluatedAttachments, evaluatedReplyMessage, nil, flows.NilMsgTopic)
msg := flows.NewMsgWppOut(urns.NilURN, nil, a.InteractionType, a.HeaderType, evaluatedHeaderText, evaluatedText, evaluatedFooter, ctaMessage, listMessage, flowMessage, orderDetailsMessage, evaluatedAttachments, evaluatedReplyMessage, nil, nil, flows.NilMsgTopic)
logEvent(events.NewMsgWppCreated(msg))
}

Expand Down
15 changes: 14 additions & 1 deletion flows/msg_wpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ type MsgWppOut struct {
FlowMessage_ FlowMessage `json:"flow_message,omitempty"`
OrderDetailsMessage_ OrderDetailsMessage `json:"order_details_message,omitempty"`
Templating_ *MsgTemplating `json:"templating,omitempty"`
Buttons_ []ButtonComponent `json:"buttons,omitempty"`
}

type ButtonComponent struct {
SubType string `json:"sub_type"`
Parameters []ButtonParam `json:"parameters"`
}

type ButtonParam struct {
Type string `json:"type"`
Text string `json:"text"`
}
type ListMessage struct {
ButtonText string `json:"button_text,omitempty"`
ListItems []ListItems `json:"list_items,omitempty"`
Expand Down Expand Up @@ -126,7 +136,7 @@ type MessageOrderAmountWithOffset struct {
Offset int `json:"offset"`
}

func NewMsgWppOut(urn urns.URN, channel *assets.ChannelReference, interactionType, headerType, headerText, text, footer string, ctaMessage CTAMessage, listMessage ListMessage, flowMessage FlowMessage, orderDetailsMessage OrderDetailsMessage, attachments []utils.Attachment, replyButtons []string, templating *MsgTemplating, topic MsgTopic) *MsgWppOut {
func NewMsgWppOut(urn urns.URN, channel *assets.ChannelReference, interactionType, headerType, headerText, text, footer string, ctaMessage CTAMessage, listMessage ListMessage, flowMessage FlowMessage, orderDetailsMessage OrderDetailsMessage, attachments []utils.Attachment, replyButtons []string, buttons []ButtonComponent, templating *MsgTemplating, topic MsgTopic) *MsgWppOut {
return &MsgWppOut{
BaseMsg: BaseMsg{
UUID_: MsgUUID(uuids.New()),
Expand All @@ -146,6 +156,7 @@ func NewMsgWppOut(urn urns.URN, channel *assets.ChannelReference, interactionTyp
FlowMessage_: flowMessage,
OrderDetailsMessage_: orderDetailsMessage,
Templating_: templating,
Buttons_: buttons,
}
}

Expand Down Expand Up @@ -174,3 +185,5 @@ func (m *MsgWppOut) FlowMessage() FlowMessage { return m.FlowMessage_ }
func (m *MsgWppOut) OrderDetailsMessage() OrderDetailsMessage { return m.OrderDetailsMessage_ }

func (m *MsgWppOut) Templating() *MsgTemplating { return m.Templating_ }

func (m *MsgWppOut) Buttons() []ButtonComponent { return m.Buttons_ }
1 change: 1 addition & 0 deletions flows/msg_wpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestMsgWppOut(t *testing.T) {
},
nil,
nil,
nil,
flows.MsgTopicAgent,
)

Expand Down
Loading