Skip to content

Commit

Permalink
Support for Referrals in WAC
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Jun 15, 2023
1 parent 52522c8 commit 5cf9f53
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions handlers/facebookapp/facebookapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ type moPayload struct {
Type string `json:"type"`
} `json:"phones"`
} `json:"contacts"`
Referral struct {
Headline string `json:"headline"`
Body string `json:"body"`
SourceType string `json:"source_type"`
SourceID string `json:"source_id"`
SourceURL string `json:"source_url"`
Image *wacMedia `json:"image"`
Video *wacMedia `json:"video"`
} `json:"referral"`
} `json:"messages"`
Statuses []struct {
ID string `json:"id"`
Expand Down Expand Up @@ -541,6 +550,16 @@ func (h *handler) processCloudWhatsAppPayload(ctx context.Context, channel couri
courier.LogRequestError(r, channel, err)
}

if msg.Referral.Headline != "" {

referral, err := json.Marshal(msg.Referral)
if err != nil {
courier.LogRequestError(r, channel, err)
}
metadata := json.RawMessage(referral)
event.WithMetadata(metadata)
}

if mediaURL != "" {
event.WithAttachment(mediaURL)
}
Expand Down

0 comments on commit 5cf9f53

Please sign in to comment.