Home > Blockchain >  AWS ChatBot in Slack: Lambda invoke unmarshal error
AWS ChatBot in Slack: Lambda invoke unmarshal error

Time:09-11

I am trying to invoke my lambda function by passing some parameter through AWS ChatBot integrated in slack channel but getting an unmarshal error

I tried to implement the command below in my slack channel integrated with AWS chatbot

@aws lambda invoke  --function-name Sk-Bot --payload "{\"Tag\": \"CDMS\"}" response.json --region ap-south-1

I got an error as like below

ExecutedVersion: $LATEST
FunctionError: Unhandled
StatusCode: 200
Payload:
{
    "errorMessage" : "Unable to unmarshal input: Extra data: line 1 column 23 - line 1 column 36 (char 22 - 35)",
    "errorType" : "Runtime.UnmarshalError",
    "requestId" : "2cf8ae8f-1da4-480d-b76b-96f06a09c45f",
    "stackTrace" : [ ]
}

my lambda code is below

def lambda_handler(event, context):
    if "Tag" in event:
       tag_value = event['Tag']
       print(tag_value)
    else:
       tag_value = None
       print("Error in Value")

I would like to pass the parameter to lambda function through the aws chatbot integrated with my slack channel. can anyone help me on these?

CodePudding user response:

If you are trying to invoke the lambda function from a Slack message (and not from the CLI) then you can do it in this way:

@aws lambda invoke  --function-name Sk-Bot --payload {"Tag": "CDMS"} --region ap-south-1

Note that there is no response.json parameter as the response won't be saved into a file. Also note how the payload is declared.

  • Related