@Override public SpeechletRequestEnvelope envelope(final AlexaRequest request) { final SystemState systemState = SystemState.builder() .withUser(session.getUser()) .withDevice(client.device) .withApiEndpoint(client.apiEndpoint) .withApplication(session.getApplication()).build(); final Context context = Context.builder().addState(systemState).build(); // ensure session is ready for another request (make an exception for session ended and launch requests) Validate.isTrue(!sessionClosed || AlexaSessionEndedRequest.class.isInstance(request) || AlexaLaunchRequest.class.isInstance(request), "Session already closed and not ready for another request."); return SpeechletRequestEnvelope.builder() .withRequest(request.getSpeechletRequest()) .withSession(request instanceof AlexaSessionStartedRequest ? getSessionWithIsNew() : session) .withVersion(AlexaClient.VERSION) .withContext(context) .build(); }