public InteractionClient( Context context, AWSCredentialsProvider credentialsProvider, Regions region, InteractionConfig interactionConfig, ClientConfiguration clientConfiguration) { if (context == null) { throw new InvalidParameterException("Context cannot be null."); } else { this.context = context; } // Check if all necessary credentials are available. if (credentialsProvider == null) { throw new InvalidParameterException("Credentials are not set."); } if (interactionConfig == null) { throw new InvalidParameterException("Interaction config is not set."); } if ((interactionConfig.getUserId() == null || interactionConfig.getUserId().isEmpty()) && !(credentialsProvider instanceof CognitoCredentialsProvider)) { throw new InvalidParameterException( "User id must be set in the config or Amazon Cognito Identity must used as the credentials provider"); } this.interactionConfig = interactionConfig; this.credentialsProvider = credentialsProvider; this.interactionListener = new DefaultInteractionListener(); // Create service low-level client. if (null == clientConfiguration) { clientConfiguration = new ClientConfiguration(); } String userAgent = INTERACTION_CLIENT_USER_AGENT; if (!StringUtils.isBlank(clientConfiguration.getUserAgent())) { userAgent += clientConfiguration.getUserAgent(); } clientConfiguration.setUserAgent(userAgent); amazonlex = new AmazonLexRuntimeClient(credentialsProvider, clientConfiguration); amazonlex.setRegion(Region.getRegion(region)); }