我想存储用户说的内容(或获取插槽的值)并将其存储在变量中。像这样:
String employee = intent.getSlot("Employee").getValue();
Alexa给出了正确的语音输出,所以它得到了插槽,但是,如果我说"彼得"然后制作一个if-statement (employee == "Peter")
似乎总是假的。有人可以解释我错过的东西吗?
public static SpeechletResponse getFact(final Intent intent, final Session session) {
Map<String, Slot> slots = intent.getSlots();
// Get the employee from the list of slots.
Slot employeeSlot = slots.get("Employee");
String speechText, repromptText;
if (employeeSlot != null) {
String employee = employeeSlot.getValue();
if (employee == "Peter") {
speechText =
String.format("Pasta is the favorite food of %s.", mitarbeiter);
} else {
// I always end up here
}
...