These docs are for v1.0. Click to read the latest docs for v2.0.

Product Recommendations

This integration step is about getting personalized product recommendations. This personalization is provided out of the box using machine intelligence and AI/ML capabilities of Raman, the AI engine of Smartech,

With this integration step, you can get following product recommendations:

  • Default recommendations
  • Best Seller recommendations
  • New products recommendations
  • Recently viewed recommendations

📘

Note:

This feature is available from v2.0.15 in Non-AndroidX SDK and from v2.2.18 in AndroidX SDK.

Getting Product Recommendations

Smartech has introduced the below methods to get different types of product recommendations.

// To get default(boxx) product recommendations.
NetcoreSDK.getBoxxReco(context, boxxRequest, boxxResponseListener);

// To get best_seller product recommendations.
NetcoreSDK.getBoxxBestSellerReco(context, boxxRequest, boxxResponseListener);

// To get recently_viewed product recommendations.
NetcoreSDK.getBoxxRecentlyViewedReco(context, boxxRequest, boxxResponseListener);

// To get new_products recommendations.
NetcoreSDK.getBoxxNewProductsReco(context, boxxRequest, boxxResponseListener);

Step 1. Create SMTBoxxRequestQuery object.

SMTBoxxRequestQuery object will contain the detailed inputs like item filters, related products, excluded products, and related action types. These inputs will be used to create the response for the product recommendation request.

SMTBoxxRequestQuery.Builder queryBuilder = new SMTBoxxRequestQuery.Builder();
SMTBoxxRequestQuery smtBoxxRequestQuery;

// Setting the item filters.
JSONObject itemFilters = new JSONObject();
itemFilters.put("boost_factor", 1);
queryBuilder.setItemFilters(itemFilters);

// Setting the related products.
String[] relatedProducts = {"PRODUCT_ID1", "PRODUCT_ID2", "PRODUCT_ID3"};
queryBuilder.setRelatedProducts(relatedProducts);

// Setting the context.
JSONObject context = new JSONObject();
context.put("boxx_location_code", 56);
queryBuilder.setContext(context);

// Setting products to exclude.
String[] exclude = {"PRODUCT_ID4", "PRODUCT_ID5"};
queryBuilder.setExclude(exclude);

// Setting transaction types not to repeat.
String[] dontRepeatTransactionTypes = {"ACTION_TYPE1", "ACTION_TYPE2"};
queryBuilder.setDontRepeatTransactionTypes(dontRepeatTransactionTypes);

// Setting whether you want to get the product properties.
queryBuilder.setGetProductProperties(true);

// Setting the num.
queryBuilder.setNum(45);

// Setting the offset.
queryBuilder.setOffset(30);

// Setting the related action type.
queryBuilder.setRelatedActionType("view");

// Setting whether you want to get the product liked disliked status.
queryBuilder.setGetProductLikedDislikedStatus(true);

// Setting whether you want to get the product aliases.
queryBuilder.setGetProductAliases(true);

// Setting extra inputs.
HashMap<String, Object> extras = new HashMap<>();
extras.put("Key1", "Value1");
extras.put("Key2", 2);
extras.put("Key3", true);
queryBuilder.setExtras(extras);

smtBoxxRequestQuery = queryBuilder.build();

Step 2. Create SMTBoxxRequest object.

After creating a SMTBoxxRequestQuery object you need to create SMTBoxxRequest object and then pass the SMTBoxxRequestQuery object in an object inside SMTBoxxRequest.

SMTBoxxRequest smtBoxxRequest = new SMTBoxxRequest();

// Setting the locale.
smtBoxxRequest.setLocale("EN");                                  

// Setting the SMTBoxxRequestQuery object to input product recommendation API.
smtBoxxRequest.setQuery(smtBoxxRequestQuery);

Step 3. Invoke method to get product recommendations.

Once you create SMTBoxxRequest object call the product recommendations method of desired recommendation type and set a listener to listen to the API response.

NetcoreSDK.getBoxxReco(this, smtBoxxRequest, new SMTBoxxResponseListener() {
  @Override
    public void onResponse(@Nullable SMTBoxxResponse smtBoxxResponse) {
    try {
      if (smtBoxxResponse != null) {
        int responseCode = smtBoxxResponse.getResponseCode();
        String responseMessage = smtBoxxResponse.getResponseMessage();
        String responseData = smtBoxxResponse.getResponseData();

        JSONObject productRecommendations = new JSONObject(responseData);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
});

The SMTBoxxResponseListener will callback onResponse() with SMTBoxxResponse object. SMTBoxxResponse will contain the below methods to get the API response details.

VariableReturn TypeDescription
getResponseCode()intResponse code of the product recommedation API request.
getResponseMessage()StringResponse message of the product recommedation API request.
getResponseData()StringResponse sent by the product recommedation API.