

Copy the below piece of sample code in the Context Handler:

response = Map();
if (context_id.equals("just_browsing")) {
    response.put("action", "reply");
    launched = answers.get("product_list").get("text");
    if (launched.containsIgnoreCase("launched")) {
        replies = Collection();
        replies.insert({
            "text": "Here is the list of newly launched cars with their specification"
        });
        replies.insert({
            "text": "Hyundai Kona - June 2019 - ₹ 8- 14 lakhs",
            "image": "https://www.hyundaiusa.com/images/vehicles/pages/vlp/2018/kona/main/compare/2018-kona-ltd-lime-twist.png "
        });
        replies.insert({
            "text": "Hyundai Eon Facelift - January 2019 - ₹ 8- 14 lakhs",
            "image": "https://i.ytimg.com/vi/tZeKlqKAPE4/maxresdefault.jpg"
        });
        replies.insert({
            "text": "Hyundai QXI - April 2019 - ₹ 8- 10 lakhs",
            "image": "https://steemitimages.com/DQmZsvXLcYpYVJCPNpwHpBJb6AL7LrVarLRN5nDwswARcdD/hyundai-carlino-compact-suv-concept.jpg "
        });
        replies.insert({
            "text": "Hyundai Grand i10 facelift - July 2019 - ₹ 5.5- 8.2 lakhs",
            "image": "https://i.ytimg.com/vi/ZNRYvAwTJio/hqdefault.jpg "
        });
        response.put("suggestions", {
            "Yes,I'm interested",
            "Not now"
        });
        response.put("replies", replies);
    } else if (launched.containsIgnoreCase("Upcoming")) {
        replies = Collection();
        replies.insert({
            "text": "Here is the list of newly launched cars with their specification"
        });
        replies.insert({
            "text": "Hyundai Kona - June 2019 - ₹ 8- 14 lakhs",
            "image": "https://www.hyundaiusa.com/images/vehicles/pages/vlp/2018/kona/main/compare/2018-kona-ltd-lime-twist.png "
        });
        replies.insert({
            "text": "Hyundai Eon Facelift - January 2019 - ₹ 8- 14 lakhs",
            "image": "https://i.ytimg.com/vi/tZeKlqKAPE4/maxresdefault.jpg"
        });
        replies.insert({
            "text": "Hyundai QXI - April 2019 - ₹ 8- 10 lakhs",
            "image": "https://steemitimages.com/DQmZsvXLcYpYVJCPNpwHpBJb6AL7LrVarLRN5nDwswARcdD/hyundai-carlino-compact-suv-concept.jpg "
        });
        replies.insert({
            "text": "Hyundai Grand i10 facelift - July 2019 - ₹ 5.5- 8.2 lakhs",
            "image": "https://i.ytimg.com/vi/ZNRYvAwTJio/hqdefault.jpg "
        });
        response.put("suggestions", {
            "Would you like to get notified on launch?",
            "Not now"
        });
        response.put("replies", replies);
    }
} else if (context_id.equals("nextoptions")) {
    option = answers.get("nextrequest").get("text");
    if (option.containsIgnoreCase("Book a test drive")) {
        response.put("action", "context");
        response.put("context_id", "testdrivebooking");
        questions = Collection();
        question1 = {
            "name": "schedule",
            "replies": {
                {
                    "text": "Select a date for test drive."
                }
            },
            "input": {
                "type": "calendar",
                "skippable": true
            }
        };
        questions.insert(question1);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("call back")) {
        response.put("action", "context");
        response.put("context_id", "callback");
        questions = Collection();
        question1 = {
            "name": "contact",
            "replies": {
                {
                    "text": "Thank You.Can I have your contact number ?"
                }
            }
        };
        questions.insert(question1);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("back to browsing")) {
        response.put("action", "end");
    } else {
        response.put("action", "context");
        response.put("context_id", "nextoptions");
        question1 = {
            "name": "nextrequest",
            "replies": {
                {
                    "text": "That's nice! What would you like me to do next ?"
                }
            },
            "suggestions": {
                "Book a test drive",
                "call back",
                " back to browsing"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    }
} else if (context_id.equals("callback")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "Thank You.You will receive a call from us in next 24 hours"
        }
    });
} else if (context_id.equals("buy")) {
    response.put("action", "context");
    response.put("context_id", "cardetails");
    question1 = {
        "name": "budget",
        "replies": {
            {
                "text": "Can you tell me the budget you have ain mind?"
            }
        },
        "input": {
            "type": "slider",
            "values": {
                "$20k",
                "$40k",
                "$60k",
                "$80k",
                "$100k"
            }
        }
    };
    question2 = {
        "name": "match_found",
        "replies": {
            "Here is what I have found for you",
            {
                "text": "What would you like to do next",
                "image": "https://www.hyundai.com/content/dam/hyundai/ww/en/images/find-a-car/all-vehicles/accent-hc-quarter-view-silk-silver-pc.png"
            }
        },
        "input": {
            "type": "select",
            "options": {
                "testdrive",
                "others",
                "preowned",
                "callagent"
            }
        }
    };
    questions = Collection();
    questions.insert(question1);
    questions.insert(question2);
    response.put("questions", questions);
} else if (context_id.equals("cardetails")) {
    info answers;
    option = answers.get("match_found").get("text");
    if (option.containsIgnoreCase("testdrive")) {
        response.put("action", "context");
        response.put("context_id", "testdrivebooking");
        questions = Collection();
        question1 = {
            "name": "schedule",
            "replies": {
                {
                    "text": "Select a date for test drive."
                }
            },
            "input": {
                "type": "calendar",
                "skippable": true
            }
        };
        questions.insert(question1);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("others") || option.containsIgnoreCase("preowned")) {
        response.put("action", "context");
        response.put("context_id", "cardetails");
        question1 = {
            "name": "budget",
            "replies": {
                {
                    "text": "Can you tell me the budget you have in mind?"
                }
            },
            "input": {
                "type": "slider",
                "values": {
                    "$20k",
                    "$40k",
                    "$60k",
                    "$80k",
                    "$100k"
                }
            }
        };
        question2 = {
            "name": "match_found",
            "replies": {
                "Here is what I have found for you",
                {
                    "text": "What would you like to do next",
                    "image": "https://www.hyundai.com/content/dam/hyundai/ww/en/images/find-a-car/all-vehicles/accent-hc-quarter-view-silk-silver-pc.png"
                }
            },
            "input": {
                "type": "select",
                "options": {
                    "testdrive",
                    "others",
                    "preowned",
                    "callagent"
                }
            }
        };
        questions = Collection();
        questions.insert(question1);
        questions.insert(question2);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("callagent")) {
        response.put("action", "end");
    }
} else if (context_id.equals("notified")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "Thank You.You have been added to our list.You will be notified on launch."
        }
    });
} else if (context_id.equals("testdrivebooking")) {
    ans = answers.get("schedule").get("text");
    if (ans == "-") {
        response.put("action", "reply");
        response.put("replies", {
            {
                "text": "Hey! Got a question? I can help."
            }
        });
        options = {
            "Just browsing",
            "I want to buy",
            "I need assistance"
        };
        response.put("suggestions", options);
    } else {
        response.put("action", "context");
        response.put("context_id", "confirmation");
        question1 = {
            "name": "contactnumber",
            "replies": {
                {
                    "text": "Please share your contact number"
                }
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    }
} else if (context_id.equals("confirmation")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "Your test drive has been scheduled.Our agent will get in touch with you in the next 24 hours"
        }
    });
} else if (context_id.equals("assist")) {
    option = answers.get("how_assist").get("text");
    if (option.containsIgnoreCase("Book for servicing")) {
        response.put("action", "context");
        response.put("context_id", "servicing");
        question1 = {
            "name": "booking",
            "replies": {
                {
                    "text": "Are you booking for a free or paid servicing ?"
                }
            },
            "input": {
                "type": "select",
                "options": {
                    "Free",
                    "Paid"
                }
            }
        };
        question2 = {
            "name": "date",
            "replies": {
                {
                    "text": "Choose a date"
                }
            },
            "input": {
                "type": "calendar",
                "skippable": true
            }
        };
        questions = Collection();
        questions.insert(question1);
        questions.insert(question2);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("Raise a complaint")) {
        response.put("action", "context");
        response.put("context_id", "complaint");
        question1 = {
            "name": "problem",
            "replies": {
                {
                    "text": "We apologise for the inconvenience.Can you please elaborate on the problem you are facing?"
                }
            }
        };
        question2 = {
            "name": "priority",
            "replies": {
                "Your request has been raised.Our service will contact you soon.Please note the reference number for future communication #12345",
                {
                    "text": "You can raised the priority on your resquest"
                }
            },
            "input": {
                "type": "select",
                "options": {
                    "Immediate",
                    "Normal",
                    "callagent"
                }
            }
        };
        questions = Collection();
        questions.insert(question1);
        questions.insert(question2);
        response.put("questions", questions);
    } else if (option.containsIgnoreCase("Roadside assistance")) {
        response.put("action", "context");
        response.put("context_id", "roadsideass");
        question1 = {
            "name": "assistance",
            "replies": {
                {
                    "text": "How would you like to assist?"
                }
            },
            "suggestions": {
                "Send a pick up truck",
                "Send a service agent",
                "Connect with an agent"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    } else {
        response.put("action", "context");
        response.put("context_id", "assist");
        question1 = {
            "name": "how_assist",
            "replies": {
                {
                    "text": "How would you like me to assist you?"
                }
            },
            "suggestions": {
                "Book for servicing",
                "Raise a complaint",
                "Roadside assistance"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    }
} else if (context_id.equals("roadsideass")) {
    ans = answers.get("assistance").get("text");
    if (ans.containsIgnoreCase("Send a pick up truck")) {
        response.put("action", "context");
        response.put("context_id", "currentlocation");
        question1 = {
            "name": "share",
            "replies": {
                {
                    "text": "Sure,please share your current location."
                }
            },
            "suggestions": {
                "Share my location",
                "No,let me send my address"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    } else if (ans.containsIgnoreCase("Send a service agent")) {
        response.put("action", "end");
        response.put("replies", {
            {
                "text": "will get back to you in another 12 hours."
            }
        });
    } else if (ans.containsIgnoreCase("Connect with an agent")) {
        response.put("action", "end");
    } else {
        response.put("action", "context");
        response.put("context_id", "roadsideass");
        question1 = {
            "name": "assistance",
            "replies": {
                {
                    "text": "How would you like to assist?"
                }
            },
            "suggestions": {
                "Send a pick up truck",
                "Send a service agent",
                "Connect with an agent"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    }
} else if (context_id.equals("currentlocation")) {
    ans = answers.get("share").get("text");
    if (ans.containsIgnoreCase("Share my location")) {
        response.put("action", "context");
        response.put("context_id", "map");
        questions = Collection();
        question1 = {
            "name": "map",
            "replies": {
                {
                    "text": "location"
                }
            },
            "input": {
                "type": "location",
                "lat": "12.844037",
                "lng": "80.060411",
                "label": "Pick a location",
                "radius": "2 kms"
            }
        };
        questions.insert(question1);
        response.put("questions", questions);
    } else if (ans.containsIgnoreCase("No,let me send my address")) {
        response.put("action", "context");
        response.put("context_id", "nosendingaddress");
        question1 = {
            "name": "current",
            "replies": {
                {
                    "text": "Sure, please share your current address."
                }
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    } else {
        response.put("action", "context");
        response.put("context_id", "currentlocation");
        question1 = {
            "name": "share",
            "replies": {
                {
                    "text": "Sure,please share your current location."
                }
            },
            "suggestions": {
                "Share my location",
                "No,let me send my address"
            }
        };
        questions = Collection();
        questions.insert(question1);
        response.put("questions", questions);
    }
} else if (context_id.equals("nosendingaddress")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "Thanks for sharing your address.Our service agent will connect with you soon"
        }
    });
    response.put("suggestions", {
        "Connect with an agent"
    });
} else if (context_id.equals("map")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "Thanks for sharing your location.Our service agent will connect with you soon"
        }
    });
    response.put("suggestions", {
        "Connect with an agent"
    });
} else if (context_id.equals("complaint")) {
    ans = answers.get("priority").get("text");
    if (ans.containsIgnoreCase("Immediate")) {
        response.put("action", "end");
        response.put("replies", {
            {
                "text": "Will call you in next 2 hours"
            }
        });
    } else if (ans.containsIgnoreCase("Normal")) {
        response.put("action", "end");
        response.put("replies", {
            {
                "text": "Will contact you in next 12 hours"
            }
        });
    } else if (ans.containsIgnoreCase("callagent")) {
        response.put("action", "end");
    }
} else if (context_id.equals("servicing")) {
    ans = answers.get("date").get("text");
    if (ans == "-") {
        response.put("action", "reply");
        response.put("replies", {
            {
                "text": "Hey! Got a question? I can help."
            }
        });
        options = {
            "Just browsing",
            "I want to buy",
            "I need assistance"
        };
        response.put("suggestions", options);
    } else {
        response.put("action", "context");
        response.put("context_id", "servicestation");
        question1 = {
            "name": "vehiclenumber",
            "replies": {
                {
                    "text": "May I have your vehicle number?"
                }
            }
        };
        question2 = {
            "name": "thank",
            "replies": {
                {
                    "text": "Thank You.Your vehicle's servicing is scheduled on " + ans + ".Will you bring your vehicle to the service station or you need a pickup ?"
                }
            },
            "input": {
                "type": "select",
                "options": {
                    "willbring",
                    "pickup"
                }
            }
        };
        questions = Collection();
        questions.insert(question1);
        questions.insert(question2);
        response.put("questions", questions);
    }
} else if (context_id.equals("servicestation")) {
    ans = answers.get("thank").get("text");
    if (ans.containsIgnoreCase("willbring")) {
        response.put("action", "context");
        response.put("context_id", "locationpoint");
        questions = Collection();
        question1 = {
            "name": "servicecentre",
            "replies": {
                {
                    "text": "Find the location of your service centre"
                }
            },
            "input": {
                "type": "location",
                "lat": "12.844037",
                "lng": "80.060411",
                "label": "Pick a location",
                "radius": "2 kms"
            }
        };
        questions.insert(question1);
        response.put("questions", questions);
    } else if (ans.containsIgnoreCase("pickup")) {
        response.put("action", "end");
        response.put("replies", {
            {
                "text": "Your car pick up is scheduled.Our field agent will connect with you soon"
            }
        });
        response.put("suggestions", {
            "Add to my contact",
            "Remind me a day before the date of servicing"
        });
    }
} else if (context_id.equals("locationpoint")) {
    response.put("action", "end");
    response.put("replies", {
        {
            "text": "options"
        }
    });
    response.put("suggestions", {
        "Thank you",
        "Remind me a day before the date of servicing"
    });
}
return response;