name = "";
email = "";
phone = "";
isVisitorName = false;
// Retrieve values from the session, if they exist
if(session.containsKey("name") && session.get("name").containsKey("value"))
{
name = session.get("name").get("value");
info "Name : " + name;
// Check if name contains "Visitor"
if(name.containsIgnoreCase("Visitor"))
{
info "Name Contains Visitor";
isVisitorName = true;
}
}
if(session.containsKey("email") && session.get("email").containsKey("value"))
{
email = session.get("email").get("value");
info "Email: " + email;
}
if(session.containsKey("phone") && session.get("phone").containsKey("value"))
{
phone = session.get("phone").get("value");
info "Phone: " + phone;
}
info "Session: " + session;
// Classify the user based on the retrieved values
if(isVisitorName && email.isNull() && phone.isNull() || name.isNull() && email.isNull() && phone.isNull())
{
info "No info or placeholder name with no email/phone";
existingUser = "New User";
}
else if(name.isNull() || email.isNull() || phone.isNull())
{
info "Some Info";
existingUser = "Existing User - Missing Info";
}
else
{
info "All info";
existingUser = "Existing User";
}
response = Map();
response.put("existingUser",existingUser);
info "Response: " + response;
return response;