diff --git a/services/external/weni/service.go b/services/external/weni/service.go index f9a14da23..aa28f99be 100644 --- a/services/external/weni/service.go +++ b/services/external/weni/service.go @@ -99,6 +99,7 @@ func (s *service) Call(session flows.Session, params assets.MsgCatalogParam, log } productRetailerIDS := []string{} + productRetailerIDMap := make(map[string]struct{}) for _, product := range productList { searchResult, trace, err := GetProductListFromSentenX(product, catalog.FacebookCatalogID(), searchThreshold, s.rtConfig) @@ -107,7 +108,12 @@ func (s *service) Call(session flows.Session, params assets.MsgCatalogParam, log return callResult, errors.Wrapf(err, "on iterate to search products on sentenx") } for _, prod := range searchResult { - productRetailerIDS = append(productRetailerIDS, prod["product_retailer_id"]) + productRetailerID := prod["product_retailer_id"] + _, exists := productRetailerIDMap[productRetailerID] + if !exists { + productRetailerIDS = append(productRetailerIDS, productRetailerID) + productRetailerIDMap[productRetailerID] = struct{}{} + } } }