AWSLexInteractionKit Class Reference

Inherits from NSObject
Declared in AWSLexInteractionKit.h
AWSLexInteractionKit.m

Other Methods

+ defaultInteractionKit

Returns the singleton interactionKit client. If the singleton object does not exist, the SDK instantiates the default service client with defaultServiceConfiguration from [AWSServiceManager defaultServiceManager]. The reference to this object is maintained by the SDK, and you do not need to retain it manually.

+ (instancetype)defaultInteractionKit

Return Value

The default interactionKit client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
     AWSServiceManager.default().defaultServiceConfiguration = configuration

     return true
  }

Objective-C

  -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
     [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

     return YES;
  }

Then call the following to get the default service client:

Swift

  let interactionKit = AWSLexInteractionKit.default()

Objective-C

  AWSLexInteractionKit *interactionKit = [AWSLexInteractionKit defaultInteractionKit];

Declared In

AWSLexInteractionKit.h

+ registerInteractionKitWithServiceConfiguration:interactionKitConfiguration:forKey:

Creates a InteractionKit client with the given service configuration and registers it for the key.

+ (void)registerInteractionKitWithServiceConfiguration:(AWSServiceConfiguration *)configuration interactionKitConfiguration:(AWSLexInteractionKitConfig *)config forKey:(NSString *)key

Parameters

configuration

A service configuration object.

key

A string to identify the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
     AWSLexInteractionKit.register(with: configuration!, forKey: "USWest2InteractionKit")

     return true
  }

Objective-C

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider];

     [AWSLexInteractionKit registerInteractionKitWithServiceConfiguration:configuration forKey:@"USWest2InteractionKit"];

     return YES;
  }

Then call the following to get the service client:

Swift

  let interactionKit = AWSLexInteractionKit(forKey: "USWest2InteractionKit")

Objective-C

  AWSLexInteractionKit *interactionKit = [AWSLexInteractionKit interactionKitForKey:@"USWest2InteractionKit"];

Warning: After calling this method, do not modify the configuration object. It may cause unspecified behaviors.

Declared In

AWSLexInteractionKit.h

+ interactionKitForKey:

Retrieves the service client associated with the key. You need to call + registerLexWithConfiguration:forKey: before invoking this method.

+ (instancetype)interactionKitForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Return Value

An instance of the service client.

Discussion

For example, set the default service configuration in - application:didFinishLaunchingWithOptions:

Swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
     let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
     let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
     AWSLexInteractionKit.register(with: configuration!, forKey: "USWest2InteractionKit")

     return true
  }

Objective-C

  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"YourIdentityPoolId"];
     AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2 credentialsProvider:credentialsProvider];
     [AWSLexInteractionKit registerInteractionKitWithServiceConfiguration:configuration forKey:@"USWest2InteractionKit"];

     return YES;
  }

Then call the following to get the service client:

Swift

  let interactionKit = AWSLexInteractionKit(forKey: "USWest2InteractionKit")

Objective-C

  AWSLexInteractionKit *interactionKit = [AWSLexInteractionKit interactionKitForKey:@"USWest2InteractionKit"];

Declared In

AWSLexInteractionKit.h

+ removeInteractionKitForKey:

Removes the interaction kit associated with the key and release it.

+ (void)removeInteractionKitForKey:(NSString *)key

Parameters

key

A string to identify the service client.

Discussion

Warning: Before calling this method, make sure no method is running on this client.

Declared In

AWSLexInteractionKit.h

– textInTextOut:

Accepts a text input and responds back with a text output

- (void)textInTextOut:(NSString *)inputText

Parameters

inputText

The text input

Declared In

AWSLexInteractionKit.h

– textInTextOut:sessionAttributes:

Accets a text input and an optional sessionAttribute dictionary and responds back with a text output.

- (void)textInTextOut:(NSString *)inputText sessionAttributes:(NSDictionary<NSString*,NSString*> *_Nullable)sessionAttributes

Parameters

inputText

The text input

sessionAttributes

Optional Session attributes dictionary

Declared In

AWSLexInteractionKit.h

– textInAudioOut:

Accepts a text input and responds back with an audio response. the playback will begin automatically unless you have set autoplayback to false in the InteractionKitConfig.

- (void)textInAudioOut:(NSString *)inputText

Parameters

inputText

The text input

Declared In

AWSLexInteractionKit.h

– textInAudioOut:sessionAttributes:

Accepts a text input and an optional sessionAttribute dictionary and responds back with an audio response. The playback will begin automatically unless you have set autoplayback to false in the InteractionKitConfig.

- (void)textInAudioOut:(NSString *)inputText sessionAttributes:(NSDictionary<NSString*,NSString*> *_Nullable)sessionAttributes

Parameters

inputText

The text input

sessionAttributes

Optional Session attributes dictionary

Declared In

AWSLexInteractionKit.h

– audioInAudioOut

Starts the microphone and listens to audio from the phone microphone and responds back with an audio response.The playback will begin automatically unless you have set autoplayback to false in the InteractionKitConfig.

- (void)audioInAudioOut

Declared In

AWSLexInteractionKit.h

– audioInAudioOutWithSessionAttributes:

Starts the microphone and listens to audio from the phone microphone and responds back with an audio response.The playback will begin automatically unless you have set autoplayback to false in the InteractionKitConfig.

- (void)audioInAudioOutWithSessionAttributes:(NSDictionary<NSString*,NSString*> *_Nullable)sessionAttributes

Parameters

sessionAttributes

Optional Session attributes dictionary

Declared In

AWSLexInteractionKit.h

– audioInTextOut

Starts the microphone and listens to audio from the phone microphone and responds back with a text response.

- (void)audioInTextOut

Declared In

AWSLexInteractionKit.h

– audioInTextOutWithSessionAttributes:

Starts the microphone and listens to audio from the phone microphone and responds back with a text response.

- (void)audioInTextOutWithSessionAttributes:(NSDictionary<NSString*,NSString*> *_Nullable)sessionAttributes

Parameters

sessionAttributes

Optional Session attributes dictionary

Declared In

AWSLexInteractionKit.h

– cancel

Cancels ongoing http call and stops listening to Microphone if Audio input was requested.

- (void)cancel

Declared In

AWSLexInteractionKit.h

Other Methods

– releaseAudioSource

Safely stop and release audioSource.

- (void)releaseAudioSource

Declared In

AWSLexInteractionKit.m