Checking to see if information provided, results in a query

Checking to see if information provided, results in a query

Below is my code for searching for a ticket - if the customer provided the ticket number and the email used it will return the ticket number and the status. 
What I would like to do is, verify that the information the customer entered matches what is on the ticket, and then return the result. If it doesn't match then give an error stating, Our system was not able to find a ticket with the information provided. 
That way people can just use this to look up tickets that do not belong to them.


response.put("action","context");
response.put("context_id","searchTicket");
ticket = answers.get("ticket").get("text");
email = answers.get("email").get("text");
if(!answers.containKey("priority"))
{
ticketSearch = zoho.desk.searchRecords(<redatcted>,"tickets",{"ticketNumber":ticket,"email":email});

info ticketSearch;
ticketStatus = ticketSearch.get("data").get(0).get("status");
ticketid = ticketSearch.get("data").get(0).get("ticketNumber");
question = {"name":"priority","replies":{"Our records indicate that your ticket number is " + ticketid,"and the status is  " + ticketStatus,"Would you like to speak to a tech regarding this ticket?"},"input":{"type":"select","options":{"Yes","No"}}};
}
else
{
priority = answers.get("priority").get("text");
if(priority.equals("No"))
{
if(!answers.containsKey("end"))
{
question = {"name":"end","replies":{"Okay thanks for contacting XMission support. Have a great day"},"input":{"type":"select","options":{"Leave for now"}}};
}
else
{
response.put("action","end");
response.put("replies",{"Bye :)"});
return response;
}
}
else if(priority.equals("Yes"))
{
response.put("action","forward");
response.put("replies",{"Please wait while we connect you to a support tech"});
return response;
}
}
response.put("questions",{question});

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now