@@ -2,7 +2,6 @@ package whatsapp
2
2
3
3
import (
4
4
"encoding/json"
5
- "fmt"
6
5
"strings"
7
6
8
7
"github.com/nyaruka/courier"
@@ -18,6 +17,7 @@ type MsgTemplating struct {
18
17
Namespace string `json:"namespace"`
19
18
Components []struct {
20
19
Type string `json:"type"`
20
+ Name string `json:"name"`
21
21
Params []struct {
22
22
Type string `json:"type"`
23
23
Value string `json:"value"`
@@ -56,7 +56,6 @@ func GetTemplatePayload(templating *MsgTemplating) *Template {
56
56
Components : []* Component {},
57
57
}
58
58
59
- buttonIndex := - 1
60
59
for _ , comp := range templating .Components {
61
60
var component * Component
62
61
@@ -87,9 +86,7 @@ func GetTemplatePayload(templating *MsgTemplating) *Template {
87
86
component .Params = append (component .Params , & Param {Type : p .Type , Text : p .Value })
88
87
}
89
88
} else if strings .HasPrefix (comp .Type , "button/" ) {
90
- buttonIndex += 1
91
-
92
- component = & Component {Type : "button" , Index : fmt .Sprint (buttonIndex ), SubType : strings .TrimPrefix (comp .Type , "button/" ), Params : []* Param {}}
89
+ component = & Component {Type : "button" , Index : strings .TrimPrefix (comp .Name , "button." ), SubType : strings .TrimPrefix (comp .Type , "button/" ), Params : []* Param {}}
93
90
94
91
for _ , p := range comp .Params {
95
92
if comp .Type == "button/url" {
0 commit comments