Search code examples
pythonpython-3.xboto3amazon-lex

Amazon Lex API checksum error


When using put_intent to update an existing intent, I provide the checksum in this way:

checksum = lex_client.get_intent(name=intent_name, version='$LATEST')['checksum']

and then use the checksum with put_intent:

lex_client.put_intent(
        name=name,
        slots=slots,
        sampleUtterances=utterances,
        checksum=checksum
    )

The exception thrown is:

botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the PutIntent operation: The fulfillment is not valid for intent 'TotalWasteForItem'. Specify another fullfillment.

Intent does not have multiple versions, '$LATEST' is the only one. Checksum is returned normally and is of type str.


Solution

  • put_intent requires the fulfillmentActivity be passed:

    fulfillmentActivity (dict) -- Describes how the intent is fulfilled. For example, after a user provides all of the information for a pizza order, fulfillmentActivity defines how the bot places an order with a local pizza store.

    You might configure Amazon Lex to return all of the intent information to the client application, or direct it to invoke a Lambda function that can process the intent (for example, place an order with a pizzeria).

    type (string) -- [REQUIRED] How the intent should be fulfilled, either by running a Lambda function or by returning the slot data to the client application.

    ...

    You can provide this to simply response with the parameters. This is good for testing.

    fulfillmentActivity={'type': 'ReturnIntent'},
    

    http://boto3.readthedocs.io/en/latest/reference/services/lex-models.html#LexModelBuildingService.Client.put_intent