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
已提問 9 個月前檢視次數 104 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南