danubeRecommendation - Examples

In the following, example requests and the according responses using the danubeRecommendation endpoint are shown.

Step 1

danube.ai’s recommendation endpoint is used here to recommend sub pages to a user. The current session consists of the route "Home - Dashboard". Based on the sent request, danube.ai recommends 3 correlated sub pages to choose from: "About", "Imprint" and "Data protection guidelines".

const testData = [
  {"page": "Homepage"},
  {"page": "Dashboard"}
];

const stringifiedTestData = JSON.stringify(testData);

POST https://api.danube.ai/graphql

body: {
  "query": "mutation ($data: RecommendationInputData!) { danubeRecommendation(data: $data) { correlatedData } }",
  "variables": {
    "data": {
      "data": {{stringifiedTestData}},
      "n": 3
    }
  }
}

Returns

{
  "data": {
    "danubeRecommendation": {
      "correlatedData": {{stringifiedCorrelatedData}}
    }
  }
}

const correlatedData = JSON.parse(stringifiedCorrelatedData);

/*
[
  {"page": "About"},
  {"page": "Imprint"},
  {"page": "Data protection guidelines"}
]
*/

Step 2

The user now continues the page navigation to “About”. The current session now consists of the route "Home - Dashboard - About". Based on the sent request, danube.ai recommends 3 correlated sub pages to choose from: "Imprint", "Data protection guidelines" and "Account Settings".

const testData = [
  {"page": "Homepage"},
  {"page": "Dashboard"},
  {"page": "About"}
];

const stringifiedTestData = JSON.stringify(testData);

POST https://api.danube.ai/graphql

body: {
  "query": "mutation ($data: RecommendationInputData!) { danubeRecommendation(data: $data) { correlatedData } }",
  "variables": {
    "data": {
      "data": {{stringifiedTestData}},
      "n": 3
    }
  }
}

Returns

{
  "data": {
    "danubeRecommendation": {
      "correlatedData": {{stringifiedCorrelatedData}}
    }
  }
}

const correlatedData = JSON.parse(stringifiedCorrelatedData);

/*
[
  {"page": "Imprint"},
  {"page": "Data protection guidelines"},
  {"page": "Account Settings"}
]
*/