public static SpeechletResponse buildSpeechletResponse(String output){
  Properties props=new Properties();
  output=parseProps(output,props);
  SimpleCard card=new SimpleCard();
  if (props.containsKey("title"))   card.setTitle(props.getProperty("title"));
  if (props.containsKey("card")) {
    String cardText=props.getProperty("card");
    if (cardText.startsWith("++"))     cardText=output + cardText.substring(2);
    card.setContent(cardText);
  }
 else   card.setContent(output);
  PlainTextOutputSpeech speech=new PlainTextOutputSpeech();
  speech.setText(output);
  SpeechletResponse response=new SpeechletResponse();
  if (props.containsKey("shouldEndSession"))   response.setShouldEndSession(Boolean.parseBoolean(props.getProperty("shouldEndSession")));
 else   response.setShouldEndSession(false);
  response.setOutputSpeech(speech);
  if (props.containsKey("reprompt")) {
    String repromptText=props.getProperty("reprompt");
    if (repromptText.startsWith("++"))     repromptText=output + repromptText.substring(2);
    PlainTextOutputSpeech repromptSpeech=new PlainTextOutputSpeech();
    repromptSpeech.setText(repromptText);
    Reprompt reprompt=new Reprompt();
    reprompt.setOutputSpeech(repromptSpeech);
    response.setReprompt(reprompt);
  }
  response.setCard(card);
  return response;
}

public static SpeechletResponse buildSpeechletResponse ( String output ) { Properties props = new Properties ( ) ; output = parseProps ( output , props ) ; SimpleCard card = new SimpleCard ( ) ; if ( props . containsKey ( "title" ) ) card . setTitle ( props . getProperty ( "title" ) ) ; if ( props . containsKey ( "card" ) ) { String cardText = props . getProperty ( "card" ) ; if ( cardText . startsWith ( "++" ) ) cardText = output + cardText . substring ( 2 ) ; card . setContent ( cardText ) ; } else card . setContent ( output ) ; PlainTextOutputSpeech speech = new PlainTextOutputSpeech ( ) ; speech . setText ( output ) ; SpeechletResponse response = new SpeechletResponse ( ) ; if ( props . containsKey ( "shouldEndSession" ) ) response . setShouldEndSession ( Boolean . parseBoolean ( props . getProperty ( "shouldEndSession" ) ) ) ; else response . setShouldEndSession ( false ) ; response . setOutputSpeech ( speech ) ; if ( props . containsKey ( "reprompt" ) ) { String repromptText = props . getProperty ( "reprompt" ) ; if ( repromptText . startsWith ( "++" ) ) repromptText = output + repromptText . substring ( 2 ) ; PlainTextOutputSpeech repromptSpeech = new PlainTextOutputSpeech ( ) ; repromptSpeech . setText ( repromptText ) ; Reprompt reprompt = new Reprompt ( ) ; reprompt . setOutputSpeech ( repromptSpeech ) ; response . setReprompt ( reprompt ) ; } response . setCard ( card ) ; return response ; }
creates and returns the visual and spoken response with shouldendsession flag .
