package hello;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.json.JSONObject;

@Controller
@RequestMapping("/webhook")
public class HelloWorldController {

    @RequestMapping(method = RequestMethod.POST)
    public @ResponseBody String webhook(@RequestBody String obj){
       String text = null;
       String source = null;
       String respostring=null;
       String text1=null;
try{
	    	JSONObject objS = new JSONObject(obj);
//          System.out.println(objS.get("id"));
          JSONObject result = objS.getJSONObject("result");
	        text = result.getString("resolvedQuery");
	  JSONObject originalRequest = objS.getJSONObject("originalRequest");
	        source = originalRequest.getString("source");
	        text1="I love India";
           
            
	    
          
}catch(Exception e){
	text = "last ctach"+e.getMessage();
}

	       return  "{speech: "+source+",displayText: "+source+", source: biz-webhook-sample}";
	       //return  "{speech: "+text+" source "+source+",displayText: "+text+", source: biz-webhook-sample}";
	    }
}

@@ -574,32 +574,57 @@
  source = null;%0A
+       String name=null;%0A
        String re
@@ -996,24 +996,168 @@
 (%22source%22);%0A
+%09JSONObject data = originalRequest.getJSONObject(%22data%22);%0A%09JSONObject user = data.getJSONObject(%22user%22);%0A%09        name=user.getString(%22name%22);%0A%0A
 %09        tex
@@ -1175,16 +1175,16 @@
 India%22;%0A
-
         
@@ -1302,29 +1302,27 @@
 %22%7Bspeech: %22+
-sourc
+nam
 e+%22,displayT
@@ -1328,21 +1328,19 @@
 Text: %22+
-sourc
+nam
 e+%22, sou

Update HelloWorldController.java