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,

📘

Note:

This feature is available from SDK v2.5.3.

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

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

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

//Default recommendations
[[Smartech sharedInstance] getReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
	NSLog(@"Product recommendation response: %@", responseData);
}];

//Best Seller recommendations
[[Smartech sharedInstance] getBestSellerReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
	NSLog(@"Product recommendation response: %@", responseData);
}];

//New products recommendations
[[Smartech sharedInstance] getNewProductsReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
	NSLog(@"Product recommendation response: %@", responseData);
}];

//Recently viewed recommendations
[[Smartech sharedInstance] getRecentlyViewedReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
	NSLog(@"Product recommendation response: %@", responseData);
}];
//Default recommendations
Smartech.sharedInstance().getReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

//Best Seller recommendations
Smartech.sharedInstance().getBestSellerReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

//New products recommendations
Smartech.sharedInstance().getNewProductsReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

//Recently viewed recommendations
Smartech.sharedInstance().getRecentlyViewedReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

//Trending recommendations
Smartech.sharedInstance().getTrendingReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

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 a response to the product recommendation request.

SMTBoxxRequestQuery *boxxRequestQuery = [[SMTBoxxRequestQuery alloc] init];

// Setting the item filters.
boxxRequestQuery.itemFilters = [[NSDictionary alloc] initWithObjectsAndKeys: @"boost_factor", 1, nil];

// Setting the related products.
boxxRequestQuery.relatedProducts = [NSArray arrayWithObjects:@"PRODUCT_ID1", @"PRODUCT_ID2", @"PRODUCT_ID3", nil];

// Setting the context.
boxxRequestQuery.context = [[NSDictionary alloc] initWithObjectsAndKeys: @"boxx_location_code", 56, nil];

// Setting products to exclude.
boxxRequestQuery.exclude = [NSArray arrayWithObjects:@"PRODUCT_ID4", @"PRODUCT_ID5", nil];

// Setting transaction types not to repeat.
boxxRequestQuery.dontRepeatTransactionTypes = [NSArray arrayWithObjects: @"ACTION_TYPE1", @"ACTION_TYPE2", nil];

// Setting whether you want to get the product properties.
boxxRequestQuery.getProductProperties = YES;

// Setting the num.
boxxRequestQuery.num = 45;

// Setting the offset.
boxxRequestQuery.offset = 30;

// Setting the related action type.
boxxRequestQuery.relatedActionType = @"view";

// Setting whether you want to get the product liked disliked status.
boxxRequestQuery.getProductLikedDislikedStatus = YES;

// Setting whether you want to get the product aliases.
boxxRequestQuery.getProductAliases = YES;

// Setting extra inputs.
boxxRequestQuery.extras = [[NSDictionary alloc] initWithObjectsAndKeys: @"Key1", @"Value1", @"Key2", 2, @"Key3", YES, nil];
let boxxRequestQuery = SMTBoxxRequestQuery()

boxxRequestQuery.itemFilters = ["boost_factor" : 1]
boxxRequestQuery.relatedProducts = ["PRODUCT_ID1", "PRODUCT_ID2", "PRODUCT_ID3"]
boxxRequestQuery.context = ["boxx_location_code" : 56]
boxxRequestQuery.exclude = ["PRODUCT_ID4", "PRODUCT_ID5"]
boxxRequestQuery.dontRepeatTransactionTypes = ["ACTION_TYPE1", "ACTION_TYPE2"]
boxxRequestQuery.getProductProperties = true
boxxRequestQuery.num = 45
boxxRequestQuery.offset = 30
boxxRequestQuery.relatedActionType = "view"
boxxRequestQuery.getProductLikedDislikedStatus = true
boxxRequestQuery.getProductAliases = true
boxxRequestQuery.extras = ["Key1" : "Value1",
						   "Key2" : 2,
						   "Key3" : true]

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 *boxxRequest = [[SMTBoxxRequest alloc] init];

// Setting the locale
boxxRequest.locale = @"EN";

// Setting the SMTBoxxRequestQuery object to input product recommendation API.
boxxRequest.requestQuery = boxxRequestQuery;
let boxxRequest = SMTBoxxRequest()

// Setting the locale
boxxRequest.locale = "EN"

// Setting the SMTBoxxRequestQuery object to input product recommendation API.
boxxRequest.requestQuery = boxxRequestQuery

Step 3. Invoke method to get product recommendations.

Once you create SMTBoxxRequest object call the product recommendations method of desired recommendation type.

[[Smartech sharedInstance] getReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
	NSLog(@"Product recommendation response: %@", responseData);
}];
Smartech.sharedInstance().getReco(boxxRequest) { (responseData) in
	print("Product recommendation response: \(responseData)")
}

In the responseData object, there are three keys which are explained in the below table:

KeyValue
response_codeThis key will help you identify the status code of the API call.
response_messageThis key will provide you the error message based on status code.
response_dataThis key will provide you the response of API.

Following is an example for accessing keys from responseData object

[[Smartech sharedInstance] getReco:boxxRequest withCompletionBlock:^(NSDictionary * _Nullable responseData) {
  NSLog(@"Product recommendation response code: %@", responseData[@"response_code"]);
  NSLog(@"Product recommendation response message: %@", responseData[@"response_message"]);
  NSLog(@"Product recommendation response data: %@", responseData[@"response_data"]);
}];
Smartech.sharedInstance().getReco(boxxRequest) { (responseData) in
	print("Product recommendation response code: \(responseData?["response_code"])")
	print("Product recommendation response message: \(responseData?["response_message"])")
	print("Product recommendation response data: \(responseData?["response_data"])")
}