简体   繁体   中英

Why is my Amazon slot returning undefined?

I'm trying to follow this tutorial here:

https://medium.com/@itsHabib/integrate-an-amazon-lex-chatbot-into-a-react-native-app-1536883ccbed

When I run my chatbot, the JSON is as follows:

{
  "dialogState": "Fulfilled",
  "intentName": "MakeUsername",
  "message": "Your username is mikeundefined",
  "messageFormat": "PlainText",
  "responseCard": null,
  "sessionAttributes": {},
  "slotToElicit": null,
  "slots": {
    "Name": "mike",
    "Number": "51"
  }
}

So, it looks like the number 51 is being stored.

But the output function:

exports.handler = (event, context, callback) => {
    console.log(event.currentIntent)
    console.log(context)
    let { Name: name } = event.currentIntent.slots 
    let { Num: number } = event.currentIntent.slots 
    callback(null, close({
        contentType: "PlainText",
        content: `Your username is ${name}${number}`
    }))
}

prints out

Your username is mikeundefined

Why is the number undefined?

该数字是未定义的,因为在第5行中,应将let { Number: number } let { Num: number } let { Number: number }

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