@ Override public void handleRequest ( final InputStream input , final OutputStream output , final Context context ) throws IOException { byte [ ] serializedSpeechletRequest = IOUtils . toByteArray ( input ) ; final AlexaSpeechlet speechlet = AlexaSpeechletFactory . createSpeechletFromRequest ( serializedSpeechletRequest , getSpeechlet ( ) , getUtteranceReader ( ) ) ; final SpeechletRequestHandler handler = getRequestStreamHandler ( ) ; try { byte [ ] outputBytes = handler . handleSpeechletCall ( speechlet , serializedSpeechletRequest ) ; output . write ( outputBytes ) ; } catch ( SpeechletRequestHandlerException | SpeechletException e ) { // wrap actual exception in expected IOException throw new IOException ( e ) ; } }
The handler method is called on a Lambda execution .