Recommendations

For the past 3 years, Shieldware, Inc. has been using the Cleverbridge platform to manage its product information. This has created certain challenges for their sales team, who frequently need to rely on Salesforce for product information and don't have time to cross-check this information with the data in the platform. To save time and ensure that the sales team always has accurate product and pricing information, Shieldware decides to invest development efforts into integrating their Salesforce account with the Cleverbridge GraphQL API. This integration allows the Shieldware e-commerce manager to manage all of Shieldware's products from within Salesforce itself, without having to open the Commerce Assistant. Since Salesforce is now the single source of truth of Shieldware's product information, it also ensures that they always have access to the most up-to-date information about their products.

You can use the GraphQL API to manage your recommendations in the following ways:

View Information for One of your Recommendations

To get the data stored in the Cleverbridge platform for a recommendation, use the recommendation query object. You must provide the id of the recommendation and specify the fields you would like to return.

Example Request

query {
  recommendation(id: 14661) {
    client {
      id
    }
    type {
      name
    }
    id
    name
    positionType {
      name
    }
    template {
      id
      name
      originalPreviewURL
    }

    validFrom
    validTo
    isActive
    isActiveAndValid
    quantityLimit {
      type {
        id
        name
      }
      value
    }
    optionType {
      name
    }
    parameter {
      name
    }
    discount {
      id
      doNotAllowOtherDiscounts
      maxIntervalCount
      maxQuantity
      showOriginalAndDiscountPrice
      priceType {
        id
        name
      }
    }

    originalProducts {
      id
    }

    recommendedProducts {
      product {
        id
      }
      position
    }

    priceConfigurationList {
      items {
        name
      }
      type {
        name
      }
    }

    clientSalesRevenueStatistics {
      last14Days {
        value
      }
      currency {
        name
      }
    }
  }
}

The API call returns the recommendation object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "recommendation": {
      "client": {
        "id": 864
      },
      "type": {
        "name": "Cross-Sell"
      },
      "id": 14661,
      "name": "Backup CD for Multiple Products",
      "positionType": {
        "name": "Lower area"
      },
      "template": null,
      "validFrom": null,
      "validTo": null,
      "isActive": true,
      "isActiveAndValid": true,
      "quantityLimit": {
        "type": {
          "id": "EQUAL",
          "name": "Equal"
        },
        "value": null
      },
      "optionType": {
        "name": "Opt-in"
      },
      "parameter": {
        "name": "cd"
      },
      "discount": {
        "id": 177244,
        "doNotAllowOtherDiscounts": false,
        "maxIntervalCount": null,
        "maxQuantity": null,
        "showOriginalAndDiscountPrice": true,
        "priceType": {
          "id": "PERCENTAGE_DISCOUNT",
          "name": "Percentage discount"
        }
      },
      "originalProducts": [
        {
          "id": 97771
        }
      ],
      "recommendedProducts": [
        {
          "product": {
            "id": 97777
          },
          "position": 50
        }
      ],
      "priceConfigurationList": null,
      "clientSalesRevenueStatistics": {
        "last14Days": {
          "value": 0
        },
        "currency": {
          "name": "US Dollar"
        }
      }
    }
  }
}

View Information for All of your Recommendations

To get the data stored in the Cleverbridge platform for all of your recommendations, use the recommendations query object. You must provide your clientId and specify the fields you would like to return.

Example Request

query {
  recommendations(clientId: 864) {
    client {
      id
    }
    type {
      name
    }
    id
    name
    creationDate
    isActiveAndValid
    parameter {
      name
    }

    orderStatistics {
      last14Days {
        value
      }
    }
  }
}

The API call returns the recommendations object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "recommendations": [
      {
        "client": {
          "id": 864
        },
        "type": {
          "name": "Cross-Sell"
        },
        "id": 14661,
        "name": "Backup CD for Multiple Products",
        "creationDate": "2012-02-27T11:38:53.194226Z",
        "isActiveAndValid": true,
        "parameter": {
          "name": "cd"
        },
        "orderStatistics": {
          "last14Days": {
            "value": 0
          }
        }
      },
      {
        "client": {
          "id": 864
        },
        "type": {
          "name": "Sub-Sell"
        },
        "id": 14598,
        "name": "Tech Support for Internet Security",
        "creationDate": "2012-02-20T14:08:17.505711Z",
        "isActiveAndValid": true,
        "parameter": {
          "name": null
        },
        "orderStatistics": {
          "last14Days": {
            "value": 0
          }
        }
      },
      {
        "client": {
          "id": 864
        },
        "type": {
          "name": "Up-Sell"
        },
        "id": 14664,
        "name": "Upgrade to Enterprise",
        "creationDate": "2012-02-27T12:54:35.755036Z",
        "isActiveAndValid": true,
        "parameter": {
          "name": null
        },
        "orderStatistics": {
          "last14Days": {
            "value": 0
          }
        }
      }
    ]
  }
}

Create a Recommendation

To create a new recommendation, use the createRecommendation mutation object. To successfully make this call, certain fields are required, including clientId,typeId, name, isActive, and discount.

Example Request

mutation {
  createRecommendation(
    input: {
      clientId: 864
      typeId: CROSS_SELLING
      name: "Backup CD for Multiple Product"
      positionTypeId: ADDITIONAL_PRODUCT_IN_CART_LOWER_AREA
      isActive: true
      validFrom: "2020-08-31T14:06:00Z"
      validTo: "2020-10-31T14:06:00Z"
      quantityLimit: { typeId: EQUAL }
      optionTypeId: OPT_IN
      parameter: {
        displayOptionId: DISPLAYS_WITH_OR_WITHOUT_PARAMETER
        name: "cd"
      }
      discount: {
        priceTypeId: PERCENTAGE_DISCOUNT
        percentagePrice: { pricePercentageValues: [{ value: 0 }] }
      }
      originalProductIds: [97771]
      recommendedProducts: [{ productId: 97777, position: 50 }]
    }
  ) {
    createdRecommendation {
      id
    }
  }
}

The API call returns the createRecommendation object with the requested fields.

Example Response

{
  "data": {
    "createRecommendation": {
      "createdRecommendation": {
        "id": 38352
      }
    }
  }
}

Delete a Recommendation

You can use the GraphQL API to delete a recommendation from the Cleverbridge platform. To do so, use the deleteRecommendation mutation object. You must specify the id of the recommendation you would like to delete.

Example Request

mutation {
  deleteRecommendation(id: 38352
) {
    deletedRecommendationId
  }
}

The API call returns the deleteRecommendation object with the requested fields.

Example Response

{
  "data": {
    "deleteRecommendation": {
      "deletedRecommendationId": 38352
    }
  }
}

Update a Recommendation

To update a recommendation, use the updateRecommendation mutation. You must provide the id of the recommendation you would like to update and specify the fields you would like to change. The following is an example of an updateRecommendation mutation that changes the position where the recommendation displays in the checkout process.

Example Request

mutation {
  updateRecommendation(
    input: { id: 38353, positionTypeId: ADDITIONAL_PRODUCT_IN_CART_UPPER_AREA }
  ) {
    updatedRecommendation {
      id
      positionType {
        id
      }
    }
  }
}

The API call returns the updateRecommendation object with the requested fields.

Example Response

{
  "data": {
    "updateRecommendation": {
      "updatedRecommendation": {
        "id": 38353,
        "positionType": {
          "id": "ADDITIONAL_PRODUCT_IN_CART_UPPER_AREA"
        }
      }
    }
  }
}