var level = payload.level.toLowerCase(); // Converting to lowercase for standardization

if (level === 'beginner') {
  payload.recommendation = 'Course: Introduction to the Market';
} else if (level === 'intermediate') {
  payload.recommendation = 'Course: Professional Development';
} else if (level === 'advanced') {
  payload.recommendation = 'Course: Career and Financial Planning';
} else {
  payload.recommendation = 'Knowledge level not recognized. Please check your response and try again.';
}

In this example, we use Execute JavaScript to segment products and filter the client, suggesting the product that best matches their current level of knowledge.
This functionality is especially recommended for infoproduct creators or affiliates.

  1. First, in the automation flow, we ask the client to inform us of their knowledge level.
  1. Next, we save the client’s response in the variable payload.level.
  1. In Execute JavaScript, we use the variable payload.level to filter the client’s level of knowledge.
  1. Finally, the result of the code will be saved in the variable payload.recommendation, which is sent to the client in the final message indicating the suggested product based on the level of knowledge they provided.
var level = payload.level.toLowerCase(); // Converting to lowercase for standardization

if (level === 'beginner') {
  payload.recommendation = 'Course: Introduction to the Market';
} else if (level === 'intermediate') {
  payload.recommendation = 'Course: Professional Development';
} else if (level === 'advanced') {
  payload.recommendation = 'Course: Career and Financial Planning';
} else {
  payload.recommendation = 'Knowledge level not recognized. Please check your response and try again.';
}