Seller Central
Seller Forums

Amazon Seller Forums » Login With Amazon » Questions about Login With Amazon

Thread: Amazon LEX returned with an error in iOS swift
This question is not answered.


Permlink Replies: 2 - Pages: 1 - Last Post: 19 Jun, 2017 2:50 PM by: Alex C. (LWA)
Anoop

Posts: 2
Registered: 13 Jun, 17 9:34 AM
Posted on: 13 Jun, 2017 2:40 AM  
Click to report abuse...   Click to reply to this thread Reply
Hi,

I integrated the amazon LEX services into the iOS app. The cognito part is working fine. But when the LEX is called it returned a bad url error saying,

error Error Domain=com.amazonaws.AWSLexErrorDomain Code=0 "null" UserInfo={NSLocalizedDescription=null, NSLocalizedFailureReason=AccessDeniedException:http://internal.amazon.com/coral/com.amazon.coral.service/}

Appdelegate Code snippet:

{
// 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
}

View Controller code snippet:

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

could anyone please help with us. Thanks in advance

Is this a helpful question? Yes 1   No
2 Replies
Sort replies by:
Anoop

Posts: 2
Registered: 13 Jun, 17 9:34 AM
Posted on: 14 Jun, 2017 2:39 AM   in response to: Anoop in response to: Anoop  
Click to report abuse...   Click to reply to this thread Reply
The issue was with IAM permission. You have to attach permission policy in IAM console.
Was this reply helpful? Yes 1   No 0
Alex C. (LWA)

Posts: 4
Registered: 21 Sep, 16 11:42 PM
Posted on: 19 Jun, 2017 2:48 PM   in response to: Anoop in response to: Anoop  
Click to report abuse...   Click to reply to this thread Reply
Glad you were able to solve your problem!

Edited by: Alex C. (LWA) on Jun 19, 2017 2:50 PM
Was this reply helpful? Yes 1   No 0