API-driven checklist items

API-driven checklist items are a big help when you need more advanced onboarding flows. For instance, if you want the user to fill multiple forms and finish an advanced account setup, it's quite difficult to accomplish using Product Fruits base functionalities. API-driven items are entirely controlled by your code.

How to use API-driven checklist items

First, add an API-driven item in the Product Fruits administration.

You must assign an Internal ID. This ID will identify the item in your code. It can be any string.

Code flow

Listen to the item-launched event and launch any action you need in your code.

window.productFruits.api.checklists.listen('item-launched', (id, internalId) => {
	console.log('Identify the item by internalId and launch an action.');
}); 

When the action in your application is done, you will probably want to mark the item as completed.

window.productFruits.api.checklists.markItemAsDone(internalId, true);

Pass internalId and that's it. If you want the checklist's popup to be expanded, set the second parameter to true.