Amazon Lex API 校验和错误

Amazon Lex API checksum error

当使用 put_intent 更新现有意图时,我以这种方式提供校验和:

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

然后使用校验和 put_intent:

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

抛出的异常是:

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

Intent没有多个版本,'$LATEST'是唯一一个。 Checksum正常返回,类型为str.

put_intent 要求传递 fulfillmentActivity

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.

...

您可以提供这个来简单地响应参数。这有利于测试。

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

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