Guided Recs
Guided Recs is our questionnaire-based recommendations, where we develop a nominal profile based on the customer's selected choices.
There is one major difference between Get Recs and Guided Recs: Guided Recs does not require an identified Object_Customer with an Object_Profile.
Guided Recs calls are based on a specific Object_Collection. The collection defaults to your primary inventory.
Object_GuidedRec is a questionnaire that gets returned by Preferabli.main().getGuidedRec(long guided_rec_id, API_ResultHandler<Object_GuidedRec> handler).
Each question Object_GuidedRecQuestion of that questionnaire contains an array of choices Object_GuidedRecChoice.
Present each question and matching set of choices to the user and gather their input. When the user is done with the questionnaire, you should be left with an array of selected choices.
Those choices are then used to generate results from Preferabli.main().getGuidedRecResults(long guided_rec_id, ArrayList
Here is an example of the whole process in one go:
Preferabli.main().getGuidedRec(Object_GuidedRec.WINE_DEFAULT, new API_ResultHandler<Object_GuidedRec>() {
@Override
public void onSuccess(Object_GuidedRec data) {
ArrayList<Long> selected_choice_ids = new ArrayList<>();
for (Object_GuidedRec.Object_GuidedRecQuestion question : data.getQuestions()) {
if (question.getChoices().size() > 0) {
// Here I am simply randomizing choices to get results. In the real world, the answers to these questions would come from the user.
selected_choice_ids.add(question.getChoices().get(new Random().nextInt(question.getChoices().size())).getId());
}
}
Preferabli.main().getGuidedRecResults(data.getId(), selected_choice_ids, null, null, Preferabli.PRIMARY_INVENTORY_ID, true, new API_ResultHandler<ArrayList<Object_Product>>() {
@Override
public void onSuccess(ArrayList<Object_Product> data) {
// Do what you like with the products returned.
}
@Override
public void onFailure(API_PreferabliException e) {
// Call failed.
}
});
}
@Override
public void onFailure(API_PreferabliException e) {
// Call failed.
}
});Updated about 1 year ago
