Skip to content

Problems linking fulfillment lambda to Lex V2 bot

0

I don't know if Lex is still supported any more, but the SDK documentation is poor and there are no decent examples to work from so I'm a bit stuck and grateful for any help.

I'm trying to create an intent with a lambda to fulfill the intent using the javascript v3 SDK. The code is:

const response = await this.send(new CreateIntentCommand({
  botId: 'P47QPI94Q6',
  botVersion: 'DRAFT',
  localeId: 'en_GB',
  intentName: '21',
  description: 'Intent 21',
  sampleUtterances: [ { utterance: 'How much data do I need?' } ],
  fulfillmentActivity: {
    type: 'CodeHook',
    codeHook: {
      messageVersion: '1.0',
      uri: 'arn:aws:lambda:eu-west-1:1234567890:function:IntentBot'
    },
    active: true
  }
}));

The intent is created successfully but I can't see the lambda in the fulfillment section of the Lex V2 console, the "active" button is off and the "Use a Lambda function for fulfillment" checkbox under "Advanced options" is not checked. Incidentally, checking this has no effect - I can't find any way to link a lambada using the console either. Amazon Q offers nothing but drivel :D

Am I just doing something obviously wrong, or is AWS Lex V2 still a work in progress?

Thanks, David

asked 2 years ago562 views

2 Answers
0

Thank you for your question, David. I understand your frustration with the documentation and examples. Let me clarify a few points about integrating Lambda functions with Amazon Lex V2 bots.

In Lex V2, the approach to integrating Lambda functions has changed compared to V1. Instead of associating a Lambda function with each intent, Lex V2 uses one Lambda function per bot alias per language. This means you don't set the Lambda function at the intent level, but rather at the bot alias level.

The code you've provided is attempting to set the Lambda function at the intent level, which is not the correct approach for Lex V2. Instead, you should:

  1. Create your intent without specifying the Lambda function.
  2. Create a bot alias.
  3. Associate the Lambda function with the bot alias.

To associate a Lambda function with your bot alias, you would use the CreateBotAlias or UpdateBotAlias API calls, specifying the Lambda ARN in the botAliasLocaleSettings parameter.

As for the console, you should be able to associate a Lambda function with your bot alias in the "Aliases" section of your bot configuration. If you're not seeing this option, make sure you're using the Lex V2 console and not the V1 console.

Lex V2 is a fully supported and production-ready service, but the transition from V1 to V2 introduced significant changes in how certain features are implemented. Your difficulty is likely due to these changes rather than Lex V2 being a work in progress.

I hope this helps clarify the situation. If you're still having trouble, you might want to review the Lex V2 documentation on integrating Lambda functions or reach out to AWS support for more detailed assistance.
Sources
Amazon Lex V1 to V2 migration guide - Amazon Lex
Integrating an AWS Lambda function into your bot - Amazon Lex
Fulfillment - Amazon Lex

answered 2 years ago

0
AWS

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.