question: private SpeechletResponse handleFirstEventRequest ( Intent intent , Session session ) { Calendar calendar = getCalendar ( intent ) ; String month = MONTH_NAMES [ calendar . get ( Calendar . MONTH ) ] ; String date = Integer . toString ( calendar . get ( Calendar . DATE ) ) ; String speechPrefixContent = "<p>For " + month + " " + date + "</p> " ; String cardPrefixContent = "For " + month + " " + date + ", " ; String cardTitle = "Events on " + month + " " + date ; ArrayList < String > events = getJsonEventsFromWikipedia ( month , date ) ; String speechOutput = "" ; if ( events . isEmpty ( ) ) { speechOutput = "There is a problem connecting to Wikipedia at this time." + " Please try again later." ; SsmlOutputSpeech outputSpeech = new SsmlOutputSpeech ( ) ; outputSpeech . setSsml ( "<speak>" + speechOutput + "</speak>" ) ; return SpeechletResponse . newTellResponse ( outputSpeech ) ; } else { StringBuilder speechOutputBuilder = new StringBuilder ( ) ; speechOutputBuilder . append ( speechPrefixContent ) ; StringBuilder cardOutputBuilder = new StringBuilder ( ) ; cardOutputBuilder . append ( cardPrefixContent ) ; for ( int i = 0 ; i < PAGINATION_SIZE ; i ++ ) { speechOutputBuilder . append ( "<p>" ) ; speechOutputBuilder . append ( events . get ( i ) ) ; speechOutputBuilder . append ( "</p> " ) ; cardOutputBuilder . append ( events . get ( i ) ) ; cardOutputBuilder . append ( "\n" ) ; } speechOutputBuilder . append ( " Wanna go deeper in history?" ) ; cardOutputBuilder . append ( " Wanna go deeper in history?" ) ; speechOutput = speechOutputBuilder . toString ( ) ; String repromptText = "With History Buff, you can get historical events for any day of the year." + " For example, you could say today, or August thirtieth." + " Now, which day do you want?" ; SimpleCard card = new SimpleCard ( ) ; card . setTitle ( cardTitle ) ; card . setContent ( cardOutputBuilder . toString ( ) ) ; session . setAttribute ( SESSION_INDEX , PAGINATION_SIZE ) ; session . setAttribute ( SESSION_TEXT , events ) ; SpeechletResponse response = newAskResponse ( "<speak>" + speechOutput + "</speak>" , true , repromptText , false ) ; response . setCard ( card ) ; return response ; } }
target:  Prepares the speech to reply to the user. Obtain events from Wikipedia for the date specified by the user (or for today's date, if no date is specified), and return those events in both speech and SimpleCard format.