By using AWS re:Post, you agree to the Terms of Use
/Amazon Lex/

Questions tagged with Amazon Lex

Sort by most recent
  • 1
  • 90 / page

Browse through the questions and answers listed below or filter and sort to narrow down your results.

1
answers
1
votes
6
views
asked 2 months ago

lex / lambda order flowers blueprints give invalid lambda response error

the order flowers blueprint runs fine on lex through console but when the lambda blueprint is attached the test fails with "Invalid Lambda Response: Received error response from Lambda: Unhandled" the log shows the error: [ERROR] KeyError: 'userId' Traceback (most recent call last): File "/var/task/lambda_function.py", line 206, in lambda_handler return dispatch(event) File "/var/task/lambda_function.py", line 182, in dispatch logger.debug('dispatch userId= {} , intentName= {} '.format(intent_request['userId'], intent_request['currentIntent']['name'])) [ERROR] KeyError: 'userId' Traceback (most recent call last): File "/var/task/lambda_function.py", line 206, in lambda_handler return dispatch(event) File "/var/task/lambda_function.py", line 182, in dispatch logger.debug('dispatch userId={}, intentName={}'.format(intent_request['userId'], intent_request['currentIntent']['name'])) the reuse of the function for fulfillment and validation is very hard to follow because the doc says: In the Editor, choose AWS Lambda function as Fulfillment, and select the Lambda function that you created in the preceding step (OrderFlowersCodeHook). Choose OK to give Amazon Lex permission to invoke the Lambda function. ..... the problem is there is no choice for the lambda function in that form nor is there one in the validation form!!! there is a reference to the function being stored in an alias but i cant find a way to tie this together. i have really tried to follow the documentation systematically but cant get through it. where am i going off the rails??? shouldnt the blueprint run without this stumbling block? this has cost me a month of hair pulling agony and is really the first step in building an index for my knowledge system already running on aws where a session could build a compound index such as "Application:Billing\Function:Encounters\Process:Create\Plan:BlueCross\Product:PPO\Coverage:Medical\Service:Physical\FromDate:01-01-2022\" it seems like a natural way to specify types and values in a modern interface. Thanks, AEH
2
answers
1
votes
9
views
asked 2 months ago

LexRuntimeV2::LexRuntimeV2Client::StartConversationAsync not generating events

We're trying to get streaming working with C++ LexRuntimeV2Client. I'm making a successful call to "PutSession," then attempting to start the stream by calling "StartConversationAsync." Code looks like this: ` LexRuntimeV2::Model::StartConversationHandler convoHandler = LexRuntimeV2::Model::StartConversationHandler(); convoHandler.SetTextResponseEventCallback(textEvent); convoHandler.SetIntentResultEventCallback(intentEvent); convoHandler.SetOnErrorCallback(errorEvent); convoHandler.SetHeartbeatEventCallback(heartbeatEvent); startConvo.WithBotId(BotId) .WithBotAliasId(BotAliasId) .WithLocaleId(Locale) .WithSessionId(ConvoSession) .WithEventStreamHandler(convoHandler) .WithConversationMode(Aws::LexRuntimeV2::Model::ConversationMode::TEXT); client.StartConversationAsync(startConvo, readyHandler, responseHandler); I'm getting a callback to "readyHandler" but none of the other callbacks are firing. I've read some sources that suggest that the issue is WinHttp client, but it's not clear how to switch to curl on Windows to test. Currently testing this on Windows, but the target deployment will be a Linux Docker container. Documentation is very very light for this API so I may definitely be calling it incorrectly. I can successfully call "RecognizeText" on the bot and get proper results so I know the client & bot are configured properly. Any help for how to make this call would be appreciated.
0
answers
0
votes
6
views
asked 3 months ago

[Issue] Lambda LexEvent returns "null" values from Lex v2 Request

**TL;DR:** The "OrderFlowers" blueprint for Lex + Lambda on .NET Core 3.1 doesn't seem to work. Instead of populating the values for `CurrentIntent` and `SlotDetails` as expected, these values are `null` instead. Note: Python and Node.js lambda equivalents seem to work just fine, but work use case requires .NET. --- ## Context - Goal: Setup blueprint "OrderFlowers" chatbot with AWS Lex v2 using .NET Core 3.1 and AWS Lambda. [(Link)](https://docs.aws.amazon.com/lex/latest/dg/gs-bp.html) - This may be an issue with Lex v2 rather than with Lambda, but this may be unlikely as Python and Node.js work fine when interchanged with the .NET lambda used. ## Description - When invoking the OrderFlowers blueprint lambda function via AWS Lex, the `LexEvent` does not populate the expected fields, such as `CurrentIntent` and `SlotDetails`. - Compare this to using the Python or Node.js blueprints which do populate the expected fields. ## Reproduction Steps 1. Create a new .NET project using the "AWS Lambda Project (.NET Core - C#)" template with the "Order Flowers Chatbot" Blueprint. 2. Log the `lexEvent` variable to CloudWatch within the **FunctionHandler** function: `LambdaLogger.Log(JsonSerializer.Serialize(lexEvent));` 3. Publish the solution to AWS Lambda (default settings, arbitrary function name). 4. Create a new Lex v2 Chatbot with the "Order Flowers Chatbot" Example. 5. Configure the new chatbot to use the new lambda function you uploaded under Bot > Alias > Language. 6. Under Intents > OrderFlowers > Fulfillment > Advanced Options, ensure "Use a Lambda function for fulfillment" is checked. 7. Save the intent, build the bot, and test the conversation. 8. An error should appear when attempting to fulfill the intent - when you check CloudWatch, the **LexEvent** body should appear with `null` values for fields such as `CurrentIntent` and `SlotDetails`. ### Logs **Lex** `Invalid Lambda Response: Received error response from Lambda: Unhandled` **CloudWatch** ``` { "CurrentIntent": null, "SlotDetails": null, "Bot": { "Name": "OrderFlowersBot", "Alias": null, "Version": "DRAFT" }, "UserId": null, "InputTranscript": "yes", "InvocationSource": "FulfillmentCodeHook", "OutputDialogMode": null, "MessageVersion": "1.0", "SessionAttributes": null, "RequestAttributes": null, "AlternativeIntents": null, "SentimentResponse": null, "RecentIntentSummaryView": null, "ActiveContexts": null } ``` ### Environment * Build Version: Amazon.Lambda.Core 2.1.0, Amazon.Lambda.LexEvents 3.0.0, Amazon.Lambda.Serialization.SystemText 2.2.0 * OS Info: Windows 10 Enterprise * Build Environment: Visual Studio 2019 * Targeted .NET Platform: .NET Core 3.1 ## Resolution - There may be an issue serializing the incoming request from Lex v2 based on the configuration laid out in the current Order Flowers .NET 3.1 blueprint. To resolve this, effort will need to be made comparing the expected Lex v2 request payload with the actual payload and the serialization may have to be adjusted accordingly.
0
answers
0
votes
12
views
asked 3 months ago

CreateBotLocale is erroring with user has no permissions

Hi, I am using java sdk to create lex bot v2. Here is the code to create a bot: ``` final DataPrivacy dataPrivacy = DataPrivacy.builder().childDirected(isDataPrivacyRequired).build(); final CreateBotRequest botRequest = CreateBotRequest.builder().botName(botName).roleArn(roleARN).idleSessionTTLInSeconds(idleSessionTTLInSeconds).dataPrivacy(dataPrivacy).build(); final CreateBotResponse response = this.lexClient.createBot(botRequest); ``` The bot gets created. As a next step I create bot locale like the following: `` ``` final CreateBotLocaleRequest botLocaleRequest = CreateBotLocaleRequest.builder().botId(botId).nluIntentConfidenceThreshold(0.4).botVersion("DRAFT").localeId("en_US").build(); final CreateBotLocaleResponse botLocaleResponse = this.lexClient.createBotLocale(botLocaleRequest); ``` The above doesnt work and I get the following error: software.amazon.awssdk.services.lexmodelsv2.model.LexModelsV2Exception: User: arn:aws:iam::xxxxxxxxxxx:user/ci-user is not authorized to perform: null (Service: LexModelsV2, Status Code: 403, Request ID: f9ebd3de-c0d4-4c3d-b1ad-8a2c38a22552, Extended Request ID: null) The only difference in creating the bot and botlocale is roleArn. I am not sure if that is creating this problem. How can I solve? Any insights? Btw I am using the following code to get the lex client: ``` public LexModelsV2Client getLexClient() { Region region = Region.AP_SOUTHEAST_1; DefaultCredentialsProvider provider = DefaultCredentialsProvider.create(); return LexModelsV2Client.builder().credentialsProvider(provider).region(region).build(); } ``` This IAM user has all AWS permission to access and i have used simlator to test the policy and it gives access. Not sure what is missing!
2
answers
0
votes
11
views
asked 5 months ago

aws lex lambda currentIntent['slots'] value for slot name changes for some utterances

I am very new to lex. I have a questionnaire workflow setup with lex and lambda, i have slot name answers which set as empty array '[]' on the first time lambda is fired to record the values (my questions state in it). But i see something weird happening with sometimes for the few words for example i have 4 words (like a multiple choice) some words are "recognized" fine but for other they change/override my slots["answers"] value. `{'messageVersion': '1.0', 'invocationSource': 'DialogCodeHook', 'userId': 'XXXXX', 'sessionAttributes': {'assessmentState': '1', 'sessionId': 'XXXXX'}, 'requestAttributes': None, 'bot': {'name': 'XXXXX', 'alias': 'XXXXX', 'version': 'XXXXX'}, 'outputDialogMode': 'Text', 'currentIntent': {'name': 'XXXXX', 'slots': {'answers': '[]'}, 'slotDetails': {'answers': {'resolutions': [{'value': '[]'}], 'originalValue': '[]'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.95}, 'alternativeIntents': [{'name': 'XXXXX1', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': None}], 'inputTranscript': 'Not at all', 'recentIntentSummaryView': [{'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[]'}, 'confirmationStatus': 'None', 'dialogActionType': 'ElicitSlot', 'fulfillmentState': None, 'slotToElicit': 'answers'}], 'sentimentResponse': None, 'kendraResponse': None, 'activeContexts': []}` this is my first request (answer to my first question) if you see `currentIntent['slots']['answers']` is an `'[]'` which i set when lambda is invoked first time even before this to render user my first question and for this question i answered 'Not at all' if you see the inputTranscript. which looks all fine but for the next question when i tried to answer with another utterance the event has changed a lot. `{'messageVersion': '1.0', 'invocationSource': 'DialogCodeHook', 'userId': 'XXXXX', 'sessionAttributes': {'assessmentState': '2', 'sessionId': 'XXXXX'}, 'requestAttributes': None, 'bot': {'name': 'XXXXX', 'alias': 'XXXXX', 'version': '23'}, 'outputDialogMode': 'Text', 'currentIntent': {'name': 'XXXXX', 'slots': {'answers': 'Several days'}, 'slotDetails': {'answers': {'resolutions': [], 'originalValue': 'Several days'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 1.0}, 'alternativeIntents': [{'name': 'XXXXX1', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': None}, {'name': 'XXXXX2', 'slots': {'foodName': None, 'delayWhen': None, 'confirmation': None, 'barcode': None, 'food': None}, 'slotDetails': {'foodName': None, 'delayWhen': None, 'confirmation': None, 'barcode': None, 'food': None}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.62}, {'name': 'XXXXX3', 'slots': {'answers': 'Several days'}, 'slotDetails': {'answers': {'resolutions': [], 'originalValue': 'Several days'}}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.51}, {'name': 'XXXXX5', 'slots': {}, 'slotDetails': {}, 'confirmationStatus': 'None', 'nluIntentConfidenceScore': 0.48}], 'inputTranscript': 'Several days', 'recentIntentSummaryView': [{'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[{"id": 1, "value": 0}]'}, 'confirmationStatus': 'None', 'dialogActionType': 'ElicitSlot', 'fulfillmentState': None, 'slotToElicit': 'answers'}], 'sentimentResponse': None, 'kendraResponse': None, 'activeContexts': []}` but here if you see `currentIntent['slots']['answers']` it is supposed to have `'[{"id": 1, "value": 0}]'` which i set after my 1st question is answered but here it is 'Several days' and if you see `recentIntentSummaryView` array's element `{'intentName': 'XXXXX', 'checkpointLabel': None, 'slots': {'answers': '[{"id": 1, "value": 0}]'},....` this has the value i set in my previous question. as far as my observation go i think it fails for some words and after a build and publish it starts to work which i dont know sometimes looks like magic and sometimes confuses what did i miss. the slot configuration i used is name: answers, type: AMAZON.streetAddress, prompt: what assessment? I used type as AMAZON.streetAddress because i had same issue on other intent and i found somewhere that AMAZON.alphaNumeric has some issue ... and change to AMAZON.streetAddress and that intent works fine, this intent also has similar config and lambda code as other but i am lost in what to do or whats happening. Please help me out, Thanks in advance.
1
answers
0
votes
14
views
asked 5 months ago
  • 1
  • 90 / page