简体   繁体   中英

How to call one intent from another intent in lambda (nodejs)

I have a lex bot which triggers lambda where slot conditions are checked(eg:phone number should be 10 digit) and it returns a closing response of text.

function closeresponse(intent_request, session_attributes, fulfillment_state, message) {
    return {
        "sessionState": {
            "sessionAttributes": session_attributes,
            "dialogAction": {
                "type": "Close"
            },
            "intent": {
                'name': intent_request[ENTITY.sessionState][ENTITY.intent][ENTITY.name],
                'state': fulfillment_state
            }
        },
        "messages": [message],
        "sessionId": intent_request["sessionId"],
        "requestAttributes": intent_request[ENTITY.requestAttributes] ? intent_request[ENTITY.requestAttributes] : {}

    }
}

after closing response i am not able trigger any function

i need to trigger another intent which has yes or no response card in same lambda function

If you want to confirm this intent dialogAction have to be confirmIntent. If you want to call another intent from this intent the dialogAction have to be elicitIntent.

The dialogAction Close indicates that there will not be a response from the user. In other words, this type doesn't take any further input and will end the entire intent. Therefore, Lex doesn't expect further input from the user.

For your case, you need to accept further input from the user so Close isn't the right dialogAction here. As Jinen said, try changing the dialogAction type to ConfirmIntent or ElicitSlot .

If you need the intent to end after the user responds with yes/no, I think ConfirmIntent is right in line with what you're looking to do. For this one, Lex asks the user a yes or no question on if the intent is complete and ready to be fulfilled.

This piece of documentation explains the different types of dialogAction . It's a useful reference for if you get stuck:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM