@OnAlias("update") public void update(TeamchatAPI api) { zd = new Zendesk.Builder("https://teamchat.zendesk.com") // Zendesk account id .setUsername("*****@*****.**") // email of zendesk account .setPassword("webaroo") .build(); // or setToken("0cf1d94606") String upCom = api.context().currentReply().getField("upCom"); // Getting existing ticket id associated with formid String[] data = ticketData.getData(api.context().currentReply().getFormId()); String ticketId = data[2]; // Creating or getting existing ticket by it id, Only Admin Ticket t = zd.getTickets(Long.parseLong(ticketId)).get(0); Comment c = new Comment(); c.setBody(upCom); t.setComment(c); // updating existing ticket in out database zd.updateTicket(t); System.out.println("Tested"); // zd.getTicketComments(Long.parseLong(ticketId)); // Room r = api.context().byId(roomId); // Chatlet cer = api.context().chatletById(formId); // Reply rep = cer.createReply().addField("upCom", upCom); // api.perform(r.reply(rep)); }
@OnAlias("getdatafeed") public void getdatafeed(TeamchatAPI api) { zd = new Zendesk.Builder("https://teamchat.zendesk.com") // Zendesk account id .setUsername("*****@*****.**") // email of zendesk account .setPassword("webaroo") .build(); // or setToken("0cf1d94606") api.perform(api.context().currentRoom().post(new TextChatlet("Thank You !!"))); DBHandler datacng = new DBHandler(); String Tkt = api.context().currentReply().getField("TicketID"); String rate = api.context().currentReply().getField("Rating"); String rcom = api.context().currentReply().getField("rcomment"); System.out.println(Tkt); System.out.println(rate); System.out.println(rcom); try { datacng.stmt.executeUpdate( "UPDATE " + datacng.configProps.getProperty("dbname").trim() + "." + datacng.configProps.getProperty("tablename").trim() + " SET rating ='" + rate + "'" + ",Rcomment ='" + rcom + "'" + " where ticketId='" + Tkt + "'"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } Ticket t = zd.getTicket(Long.parseLong(Tkt)); SatisfactionRating sr = new SatisfactionRating(); sr.setScore(rate); sr.setComment(rcom); t.setSatisfactionRating(sr); // updating existing ticket in out database zd.updateTicket(t); System.out.println("Tested"); }
Object[] processTicket(Ticket ticket) { return new Object[] {ticket.getId()}; }
@OnAlias("query") public void query(TeamchatAPI api) { zd = new Zendesk.Builder("https://teamchat.zendesk.com") // Zendesk account id .setUsername("*****@*****.**") // email of zendesk account .setPassword("webaroo") .build(); // or setToken("0cf1d94606") String sub = api.context().currentReply().getField("subject"); String com = api.context().currentReply().getField("comment"); String con = api.context().currentReply().getField("contact"); // Setting comment Comment c = new Comment(); c.setBody(com); // Creating a new ticket, administrator privilege is required Ticket ticket = new Ticket(); ticket.setSubject(sub); ticket.setComment(c); ticket = zd.createTicket(ticket); ticketId = String.valueOf(ticket.getId()); requesterId = String.valueOf(ticket.getRequesterId()); String stat = "open"; String rat = ""; String Rc = ""; Form f = api.objects().form(); f.addField(api.objects().input().label("Comment").name("upCom")); PrimaryChatlet prime = new PrimaryChatlet(); prime .setQuestionHtml( "<h4><b>Ticket Details:</b></h4>" + "<ul type=\"square\"; style=\"color:#359FD8\";><li><a1 style=\"color:black\";><b>Ticket ID- </b></a1><a2 style=\"color:#359FD8\";>" + ticketId + "</a2></li><li><a3 style=\"color:black\";><b>Requester ID- </b></a3><a4 style=\"color:#359FD8\";>" + requesterId + "</a4></li><li><a5 style=\"color:black\";><b>Subject - </b></a5><a6 style=\"color:#359FD8\";>" + sub + "</a6></li><li><a7 style=\"color:black\";><b>Comment - </b></a7><a8 style=\"color:#359FD8\";>" + com + "</a8></li></ul>") .setReplyScreen(f) .setReplyLabel("Update") .setDetailsLabel("Update") .showDetails(true) .alias("update"); api.perform(api.context().currentRoom().post(prime)); roomId = api.context().currentRoom().getId(); formId = prime.getFormId(); comment = com; contact = con; status = stat; rating = rat; Rcomment = Rc; // System.out.println("TICKET ID"+ticketId); // System.out.println("REQUESTER ID"+requesterId); // System.out.println("FORM ID"+formId); // System.out.println("ROOM ID"+roomId); // System.out.println(status); ticketData.setData( roomId, formId, ticketId, requesterId, comment, contact, status, rating, Rcomment); // Saving ticketid with formid for further replies // api.data().addField (formId, "RoomID", roomId); // api.data().addField (formId, "FormID", formId); // api.data().addField (formId, "TicketID", ticketId); // api.data().addField (formId, "RequesterID", requesterId); }