Search code examples
pythonmachine-learningaws-lambdachatbotamazon-lex

Two amazon lambda functions for one lex bot


Can we use Two amazon lambda functions for one lex bot if one lambda function in python and other in node.js?


Solution

  • Yes we can have different Lambda functions for each intent in any language of your choice. So if you are using 10 intents in one Lex bot then you can have 10 different Lambda functions for each of your intent.

    However if you are asking for two lambda functions for single intent then it is not possible, but still you can call as many lambda functions from your defined Lambda function.

    Below is the code (python) to invoke another lambda function:

    import boto3
    import json
    
    lambda_client = boto3.client('lambda')
    a=[1,2,3]
    x = {"list" : a}
    invoke_response = lambda_client.invoke(FunctionName="name_of_other_lambda",
                                           InvocationType='RequestResponse',
                                           Payload=json.dumps(x))
    print (invoke_response['Payload'].read())
    

    Hope it help.