For the complete documentation index, see llms.txt. This page is also available as Markdown.

Communication

Route Web Components requests through your backend to enrich FactFinder responses.

Communication

By default, FactFinder Web Components communicate directly with FactFinder. This is configured in the ff-communication element.

All actions and requests are performed automatically depending on the element that was clicked. For example, if the user clicks an ff-asn-group-element, a filter action is executed. FactFinder Web Components are data driven.

They expect a service capable of understanding the FactFinder API invocations and returning data as FactFinder would return it.

Change the Communication Flow

In some situations, you may not want FactFinder Web Components to communicate directly with FactFinder. Enriching product data with the latest stock might be one of these use cases.

Configure FactFinder Web Components to communicate with your shop backend by changing the url attribute on the ff-communication element.

Detailed Overview of Communication

The following illustrates the five steps to enrich search responses with the latest data from 3rd-party services.

1

AJAX Request

When the user interacts with the search result page, AJAX requests are made at certain points. These AJAX requests need to be made to the shop system.

Change the URL settings in the ff-communication element.

<!-- Regular setup -->
<ff-communication url="https://your.factfinder.com/FACT-Finder">
</ff-communication>

<!-- Change the URL accordingly -->
<ff-communication url="https://your.shop-endpoint.com/optional-path">
</ff-communication>
2

Forward the HTTP Request to FactFinder

The request made by FactFinder Web Components will look something like:

https://your.shop-endpoint.com/optional-path/rest/v5/search/shoeshop_en?query=shoe

The URL follows this pattern:

[protocol]://[domain + port]/[Optional-Path]/[REST-Endpoint]?[HTTP-Params]

Basically, all your shop system needs to do is replace everything before the REST-Endpoint with the original FactFinder URL.

Taking the URLs from the previous step, the URL changes would look like this:

Client to shop system:
https://your.shop-endpoint.com/optional-path/rest/v5/search/shoeshop_en?query=shoe

Shop system to FactFinder:
https://your.factfinder.com/FACT-Finder/rest/v5/search/shoeshop_en?query=shoe
3

Receive JSON Response

Next, your shop system issues the request to FactFinder and receives the data.

4

Enrich JSON Response with Additional Data

Let's say you want to add the latest stock to your received records. Consider the following response:

{
  "hits": [
    {
      "foundWords": [],
      "id": "f2d296767b851bcf56074343a1a805a9",
      "masterValues": [],
      "position": 1,
      "score": 106.07055,
      "variantValues": [
        {
          "title": "Shoe A",
          "price": 199.90,
          "...": "..."
        }
      ]
    }
  ]
}

The variantValues list inside the hits list is the correct place to add product-specific data. Retrieve the stock data from your data source and add it to the JSON response.

The result would look like this:

{
  "hits": [
    {
      "foundWords": [],
      "id": "f2d296767b851bcf56074343a1a805a9",
      "masterValues": [],
      "position": 1,
      "score": 106.07055,
      "variantValues": [
        {
          "title": "Shoe A",
          "price": 199.90,
          "STOCK": 12,
          "...": "..."
        }
      ]
    }
  ]
}
5

Return Data to FactFinder Web Components

You are done manipulating the JSON response. Lastly, send the data back to the client, where you can integrate your enriched search response.

Last updated

Was this helpful?