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});