0
私のアプリケーションにAmazon LEXを統合しようとしています。最初はAmazonのコグニートを追加しました.Cognito Idを入手しました。私はLEXと通信しようとしたとき、このAmazon LEXがiOS Swiftでエラーを返す
Error Domain=com.amazonaws.AWSLexErrorDomain Code=0 "null" UserInfo={NSLocalizedDescription=null, NSLocalizedFailureReason=AccessDeniedException:http://internal.amazon.com/coral/com.amazon.coral.service/}
AppDelegateコードのように言って、エラーを返して次へ:
{
// Override point for customization after application launch.
AWSDDLog.sharedInstance.logLevel = .verbose
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: “given the Id”)
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
credentialProvider.getIdentityId().continueWith(block: { (task) -> AnyObject? in
if (task.error != nil)
{
print("Error: " + task.error!.localizedDescription)
}
else
{
let cognitoId = task.result!
print("Cognito Id is, \(cognitoId)")
}
return task
})
let chatConfig = AWSLexInteractionKitConfig.defaultInteractionKitConfig(withBotName: "BookTrip", botAlias: "Chatting")
AWSLexInteractionKit.register(with: configuration!, interactionKitConfiguration: chatConfig, forKey: "AWSLexVoiceButton")
chatConfig.autoPlayback = false
//AWSLexInteractionKit.register(with: configuration!, interactionKitConfiguration: chatConfig, forKey: "chatConfig")
return true
}
のViewControllerコード:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
(self.voiceButton)?.delegate = self
// (self.voiceButton as AWSLexVoiceButton).delegate = self
}
func voiceButton(_ button: AWSLexVoiceButton, on response: AWSLexVoiceButtonResponse) {
DispatchQueue.main.async(execute: {
// `inputranscript` is the transcript of the voice input to the operation
print("Input Transcript: \(String(describing: response.inputTranscript))")
if let inputTranscript = response.inputTranscript {
self.input.text = "\"\(inputTranscript)\""
}
print("on text output \(String(describing: response.outputText))")
self.output.text = response.outputText
})
}
public func voiceButton(_ button: AWSLexVoiceButton, onError error: Error) {
print("error \(error)")
}
は、私が合格する必要がありますかLEXと一緒にCognito Id。誰でも私がここで間違っていることを助けてください。前もって感謝します。
この許可はありますか?同じ場所に詰まっています – GIJOW
コンソールのIAM権限。私は、amazonポータルにログインして、あなたのbotにIAMの許可を加えます – suji