AWSLexInteractionKit

Objective-C

@interface AWSLexInteractionKit : NSObject

/*
 * The Tnteraction Kit config.
 */
@property (nonatomic, strong) AWSLexInteractionKitConfig *interactionKitConfig;

@property (nonatomic, weak) id<AWSLexInteractionDelegate> interactionDelegate;

@property (nonatomic, weak) id<AWSLexMicrophoneDelegate> microphoneDelegate;

@property (nonatomic, weak) id<AWSLexAudioPlayerDelegate> audioPlayerDelegate;

/**
 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.
 
 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];
 
 @return The default interactionKit client.
 */
+ (instancetype)defaultInteractionKit;


/**
 Creates a InteractionKit client with the given service configuration and registers it for the key.
 
 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.
 
 @param configuration A service configuration object.
 @param key           A string to identify the service client.
 */
+ (void)registerInteractionKitWithServiceConfiguration:(AWSServiceConfiguration *)configuration
                           interactionKitConfiguration:(AWSLexInteractionKitConfig *)config
                                                forKey:(NSString *)key;

/**
 Retrieves the service client associated with the key. You need to call `+ registerLexWithConfiguration:forKey:` before invoking this method.
 
 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"];
 
 @param key A string to identify the service client.
 
 @return An instance of the service client.
 */
+ (instancetype)interactionKitForKey:(NSString *)key;

/**
 Removes the interaction kit associated with the key and release it.
 
 @warning Before calling this method, make sure no method is running on this client.
 
 @param key A string to identify the service client.
 */
+ (void)removeInteractionKitForKey:(NSString *)key;

/**
 Accepts a text input and responds back with a text output
 
 @param inputText The text input
 */
- (void)textInTextOut:(NSString *)inputText;

/**
 Accets a text input and an optional sessionAttribute dictionary and responds back with a text output.
 
 @param inputText The text input
 @param sessionAttributes Optional Session attributes dictionary
 */
- (void)textInTextOut:(NSString *)inputText sessionAttributes:(NSDictionary<NSString *, NSString *> * _Nullable)sessionAttributes;

/**
 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.
 
 @param inputText The text input
 */
- (void)textInAudioOut:(NSString *)inputText;

/**
 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.
 
 @param inputText The text input
 @param sessionAttributes Optional Session attributes dictionary
 */
- (void)textInAudioOut:(NSString *)inputText sessionAttributes:(NSDictionary<NSString *, NSString *> * _Nullable)sessionAttributes;

/**
 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;

/**
 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.
 
 @param sessionAttributes Optional Session attributes dictionary
 */
- (void)audioInAudioOutWithSessionAttributes:(NSDictionary<NSString *, NSString *> * _Nullable)sessionAttributes;

/**
 Starts the microphone and listens to audio from the phone microphone and responds back with a text response.
 */
- (void)audioInTextOut;

/**
 Starts the microphone and listens to audio from the phone microphone and responds back with a text response.
 
 @param sessionAttributes Optional Session attributes dictionary
 */
- (void)audioInTextOutWithSessionAttributes:(NSDictionary<NSString *, NSString *> * _Nullable)sessionAttributes;

/**
 Cancels ongoing http call and stops listening to Microphone if Audio input was requested.
 */
- (void)cancel;

@end

Swift

class AWSLexInteractionKit : NSObject

Undocumented

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, strong) AWSLexInteractionKitConfig *interactionKitConfig

    Swift

    var interactionKitConfig: AWSLexInteractionKitConfig { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, weak) id<AWSLexInteractionDelegate> interactionDelegate

    Swift

    weak var interactionDelegate: AWSLexInteractionDelegate? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, weak) id<AWSLexMicrophoneDelegate> microphoneDelegate

    Swift

    weak var microphoneDelegate: AWSLexMicrophoneDelegate? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, weak) id<AWSLexAudioPlayerDelegate> audioPlayerDelegate

    Swift

    weak var audioPlayerDelegate: AWSLexAudioPlayerDelegate? { get set }
  • 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.

    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];
    

    Declaration

    Objective-C

    + (nonnull instancetype)defaultInteractionKit;

    Swift

    class func `default`() -> Self

    Return Value

    The default interactionKit client.

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

    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.

    Declaration

    Objective-C

    + (void)registerInteractionKitWithServiceConfiguration:(id)configuration
                               interactionKitConfiguration:
                                   (nonnull AWSLexInteractionKitConfig *)config
                                                    forKey:(nonnull NSString *)key;

    Swift

    class func register(withServiceConfiguration configuration: Any!, interactionKitConfiguration config: AWSLexInteractionKitConfig, forKey key: String)

    Parameters

    configuration

    A service configuration object.

    key

    A string to identify the service client.

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

    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"];
    

    Declaration

    Objective-C

    + (nonnull instancetype)interactionKitForKey:(nonnull NSString *)key;

    Swift

    convenience init(forKey key: String)

    Parameters

    key

    A string to identify the service client.

    Return Value

    An instance of the service client.

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

    Warning

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

    Declaration

    Objective-C

    + (void)removeInteractionKitForKey:(nonnull NSString *)key;

    Swift

    class func remove(forKey key: String)

    Parameters

    key

    A string to identify the service client.

  • Accepts a text input and responds back with a text output

    Declaration

    Objective-C

    - (void)textInTextOut:(nonnull NSString *)inputText;

    Swift

    func text(inTextOut inputText: String)

    Parameters

    inputText

    The text input

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

    Declaration

    Objective-C

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

    Swift

    func text(inTextOut inputText: String, sessionAttributes: [String : String]? = nil)

    Parameters

    inputText

    The text input

    sessionAttributes

    Optional Session attributes dictionary

  • 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.

    Declaration

    Objective-C

    - (void)textInAudioOut:(nonnull NSString *)inputText;

    Swift

    func text(inAudioOut inputText: String)

    Parameters

    inputText

    The text input

  • 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.

    Declaration

    Objective-C

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

    Swift

    func text(inAudioOut inputText: String, sessionAttributes: [String : String]? = nil)

    Parameters

    inputText

    The text input

    sessionAttributes

    Optional Session attributes dictionary

  • 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.

    Declaration

    Objective-C

    - (void)audioInAudioOut;

    Swift

    func 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.

    Declaration

    Objective-C

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

    Swift

    func audioInAudioOut(sessionAttributes: [String : String]? = nil)

    Parameters

    sessionAttributes

    Optional Session attributes dictionary

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

    Declaration

    Objective-C

    - (void)audioInTextOut;

    Swift

    func audioInTextOut()
  • Starts the microphone and listens to audio from the phone microphone and responds back with a text response.

    Declaration

    Objective-C

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

    Swift

    func audioInTextOut(sessionAttributes: [String : String]? = nil)

    Parameters

    sessionAttributes

    Optional Session attributes dictionary

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

    Declaration

    Objective-C

    - (void)cancel;

    Swift

    func cancel()