End conversation flow after Connecting lambda function to aws lex v2 chatbot

0

Hi! I am eager to build my own chatbot using aws lex v2 and aws lambda v1. I've succeeded to create intents, utterances, slots, fulfillment, closing response. I am able to create, update, delete the intent, slots whenever I want. The step where I am is attach the lambda function uploaded to the aws lambda console to aws lex v2 console. Actually, i did this by adding the lambda function when testing as I am curretly at the stage of draft version. When I build and test, everything goes well without any error. But, the problem is when the labmda function is executed, the next step which is closing response did not follow even though I set the closing response which works well when I did not attach the lambda to the aws lex v2.

[1] The conversation flow just stops after the labmda function's executed. [2] Furthermore, it did not show success or failure messages I've set in the fulfillment section. This also works well when I did not attach the lambda function.

I attach the code for the testing lambda function. If you need something more to determine the problem, please feel free to leave a comment. Thank you for your help!

  • [3] One more thing, my coworker told me it's impossible to make both the closing response and Lambda function work simultaneously. I also want to check if it is true. Thank you!

public class LambdaReservation implements RequestHandler<Object,Object>{

@Override
public Map<String, Object> handleRequest(Object input, Context context) {
    context.getLogger().log("Input: " + input);


    Map<String, Object> intent = new HashMap<>();
    intent.put("name", "Reservation");

    intent.put("state", "Fulfilled");
    intent.put("confirmationState", "None");


    Map<String, Object> message = new HashMap<>();
    message.put("contentType", "PlainText");
    message.put("content", "Hello from Lambda!");
    List<Map<String, Object>> messages = new ArrayList<>();
    messages.add(message);

    Map<String, Object> dialogAction = new HashMap<>();
    dialogAction.put("type", "Close");
    dialogAction.put("fulfillmentState", "Fulfilled");
    dialogAction.put("message", message);

    Map<String, Object> sessionState = new HashMap<>();
    sessionState.put("intent", intent);
    sessionState.put("sessionAttributes", new HashMap<>());
    sessionState.put("dialogAction",dialogAction);

    Map<String, Object> response = new HashMap<>();
    response.put("sessionState", sessionState);
    response.put("messages", messages);
    response.put("requestAttributes", new HashMap<>());

    return response;

}

}

frank
asked 8 months ago100 views
No Answers

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.

Guidelines for Answering Questions