0

我試着去亞馬遜LEX融入我的應用程序返回錯誤。最初我添加了亞馬遜認知,並從中得到了Cognito Id。當我試圖與LEX溝通將返回一個錯誤,說這樣亞馬遜LEX與iOS斯威夫特

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)") 
    } 

我是否需要通過認證ID以及LEX。任何人都可以請幫助我這裏有什麼問題。提前致謝。

回答

0

最後我想出瞭解決方案。這個問題與IAM許可。您必須在IAM控制檯中附加權限策略。希望這對你有所幫助。

+0

這允許嗎?陷在控制檯同一個地方 – GIJOW

+0

IAM權限。我登錄到亞馬遜門戶並將IAM權限添加到您的機器人 – suji