- Newest
- Most votes
- Most comments
This doesn't work ..... it's just bad advice.
lambdaArn is wrong, it should be lambdaARN. And updating the DRAFT botAlias (you can't update the botAlias of a later version) does not cause the FallbackIntent to use a lambda - as demonstrated in the console:
Can anyone help? Is Lex V2 actually in use anywhere or is it just a prototype project?
answered 2 years ago
Hi there!
Looking at your code sample it looks like there are a couple of changes needed
- Ensure to pass in the
parentIntentSignatureattribute with a value ofAMAZON.FallbackIntentotherwise it thinks you are trying to update the built-in intent to be a custom one. - The fulfillmentCodeHook need both
activeandenabledset to true. - The code hook specification is only needed at the bot alias level so you can remove it. Instead you need the
postFulfillmentStatusSpecification
Here is an example of those updates:
await lexClient.send(new UpdateIntentCommand(
{
botId: 'XX1R6TXXQU',
botVersion: 'DRAFT',
localeId: 'en_GB',
intentId: 'FALLBCKINT',
intentName: 'FallbackIntent',
description: 'Default intent when no other intent matches',
parentIntentSignature: 'AMAZON.FallbackIntent',
fulfillmentCodeHook: {
active: true,
enabled: true,
postFulfillmentStatusSpecification: {
failureNextStep: { dialogAction: { type: 'EndConversation' }, intent: {} },
successNextStep: { dialogAction: { type: 'EndConversation' }, intent: {} },
timeoutNextStep: { dialogAction: { type: 'EndConversation' }, intent: {} }
}
}
}
))
answered 2 years ago
I understand your frustration with connecting the Lex V2 FallbackIntent to a Lambda function. The issue you're encountering is because the FallbackIntent is a built-in intent, and it cannot be directly modified using the UpdateIntentCommand like you would with custom intents.
Instead, to connect the FallbackIntent to your Lambda function in Lex V2, you need to configure it at the bot level rather than the intent level. Here's how you can do it using the JavaScript SDK:
- Use the UpdateBotAlias command to associate your Lambda function with the bot alias.
- In the same command, specify that you want to use this Lambda for the FallbackIntent.
Here's an example of how you might structure this command:
const updateBotAliasCommand = new UpdateBotAliasCommand({ botAliasId: 'YOUR_BOT_ALIAS_ID', botId: 'XX1R6TXXQU', botAliasName: 'YOUR_BOT_ALIAS_NAME', botVersion: 'DRAFT', botAliasLocaleSettings: { 'en_GB': { enabled: true, codeHookSpecification: { lambdaCodeHook: { lambdaArn: 'arn:aws:lambda:eu-west-1:1234567890:function:CB013bc184-6c99-4011-9711-ba77e98', codeHookInterfaceVersion: '1.0' } } } } }); try { const response = await lexClient.send(updateBotAliasCommand); console.log("Bot alias updated successfully:", response); } catch (error) { console.error("Error updating bot alias:", error); }
After updating the bot alias, you need to rebuild your bot for the changes to take effect. You can do this using the BuildBotLocale command.
Remember that in Lex V2, you use a single Lambda function for all intents, including the FallbackIntent. Your Lambda function should check the 'invocationSource' and the intent name in the input event to determine how to handle different intents, including the FallbackIntent.
This approach should allow you to connect your Lambda function to the FallbackIntent without directly modifying the built-in intent itself.
Sources
Attach an AWS Lambda function to a bot using API operations - Amazon Lex
AMAZON.FallbackIntent - Amazon Lex
Relevant content
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated 4 years ago
