coopjakob / memory

MIT License
0 stars 0 forks source link

Using the right Rich Relevance implementation #1

Closed coopjakob closed 4 years ago

coopjakob commented 4 years ago

Rich Relevance (RR) gives us a personalised list of product recommendations. They have API for JSON data, and request URL:s for tracking. Coop aslo have API for product data.

RR have AI strategies that will need some tracking data from us. When they send a list every product in the list is marked as viewed, so we can't just get a list of 100 and show 4.

When someone click a product or add to cart another request should be made. The URL:s is received by the initial request.

This is an example of a request: https://www.coop.se/ws/v2/coop/users/anonymous/products/recommend-segmented?placements=home_page.2020_start_few&fields=DEFAULT&storeId=${this.storeId}&rrSessionId=${this.rrSessionId}&rcs=${this.rcs}`

storeId might be 016001 for Stockholm. rrSessionId is the session (even if you're logged in) rcs is sent as a response of the first request and can be added to session storage.

This will receive a ordered (sorted by rank) list from RR, and our Hybris API (coop.se/ws) will update it with updated (but cached) content.

We can also request data directly from RR: https://recs.richrelevance.com/rrserver/api/rrPlatform/recsForPlacements?apiKey=c5aa3f92242c950c&apiClientKey=182bc783b3c1fff9&returnMinimalRecItemData=true&rcs=eF5jYSlN9jBIMzI3M0lL000yTUvVNTG0SNY1TDUxBRKmyUCcmmZpmsiVW1aSmSJgaG5sqWuoawgApuYO1A&sessionId=daj0jpfe1p3xu3c&placements=home_page.2020_start_few&rid=016001

In this case I added returnMinimalRecItemData=true to show that we might have a problem with this data being old, and that it should not be used. But a list of ID is fine, because we also have an API that can receive specific product data...

https://www.coop.se/ws/v2/coop/users/anonymous/products/2097522500000?fields=BASIC

My suggestion would be to only get a list of ID directly from RR and then populate each ID with data for specific products. Then the data, promotions etc, will never be wrong.

coopjakob commented 4 years ago

Oh, I forgot to mention that I created two "placements" in Rich Relevance. One with just a few product and one for many more products.

My solution is that "a few products" is loaded for everyone. Then, if you're on mobile, a button will be shown to display the full list. And on desktop this will be loaded automatically.

I like this flow because it's a very similar technical solution on mobile and desktop. Instead of building separate solutions for mobile and one for desktop.

But yes, duplicates needs to be removed before showing the full list, because the response from the first request is not automatically removed on the second one.

benjick commented 4 years ago

rcs is sent as a response of the first request and can be added to session storage.

This is done

storeId might be 016001 for Stockholm.

rrSessionId is the session

I'm guessing these values should come from the parent application?

In this case I added returnMinimalRecItemData=true to show that we might have a problem with this data being old, and that it should not be used. But a list of ID is fine, because we also have an API that can receive specific product data...

Can you explain this a bit more? Not really understanding the purpose. How does "data being old" relate to "a list of ID"?

coopjakob commented 4 years ago

This is done

Can you put a link to where the code is?

I'm guessing these values should come from the parent application?

storeId comes from COOP.config.coopStore rrSessionId comes from COOP.config.rrSessionId

Can you explain this a bit more? [...]

In my suggestion we only take the list of product ID's directly from Rich Relevance (RR), and populate it with latest product data from another API to get the latest prices.

The solution on the website today is that we use another API that will take data from RR and populate it with data and then send it to us including data.

What kind of solution do you fancy?

coopjakob commented 4 years ago

Maybe it's just easier to take the data from the API where we get both the list of products to show, and the data about each product. For now, and for the MVP at least.

This is what we use on coop.se today.

https://recs.richrelevance.com/rrserver/api/rrPlatform/recsForPlacements?apiKey=c5aa3f92242c950c&apiClientKey=182bc783b3c1fff9&returnMinimalRecItemData=false&rcs=eF5jYSlN9jBIMzI3M0lL000yTUvVNTG0SNY1TDUxBRKmyUCcmmZpmsiVW1aSmSJgaG5sqWuoawgApuYO1A&sessionId=daj0jpfe1p3xu3c&placements=home_page.2020_start_few&rid=016001

But I don't know if it would be the best solution.

benjick commented 4 years ago

You can see the rcs implementation here: https://github.com/benjick/kenora-thistles-nuxt/blob/master/store/products.ts

coopjakob commented 4 years ago

Maybe we should fetch latest updates using this api!?

https://www.coop.se/ws/v2/coop/users/a148649e-235a-4157-8df8-5b2aa424ea7d/products/productdetails/7622300247942,7310960024415,7300200068002,7311379532058,7310090771623,7310470030319,7310090225249,7300156584151,7310040027770,7310072000277,7311803544008,2340418100007,7394048011238,7311070347272,7310867561006,5711953041976?fields=FULL&storeId=016001

coopjakob commented 4 years ago

Seems like this request is used today sometimes:

https://www.coop.se/api/hybris/ecommerce/product/list?id%5B%5D=23307309&id%5B%5D=7310867564106&id%5B%5D=0&id%5B%5D=129153042&id%5B%5D=2340398000007&id%5B%5D=8885730&id%5B%5D=2340380400006&id%5B%5D=18848&id%5B%5D=7310290002756&id%5B%5D=18850&id%5B%5D=7310290002763&id%5B%5D=18846&id%5B%5D=7310290002749&id%5B%5D=23988&id%5B%5D=7313940011566&id%5B%5D=20090&id%5B%5D=7310511214401&id%5B%5D=20086&id%5B%5D=7310511210403&_=1596458746181