use of com.amazon.speech.speechlet.IntentRequest in project amos-ss17-alexa by c-i-ber.
the class BankAccountService method onIntent.
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
IntentRequest request = requestEnvelope.getRequest();
Account account = AccountFactory.getInstance().getAccount(number);
String speechText = "Was möchtest du über dein Konto erfahren?";
String repromptText = "Was möchtest du über dein Konto erfahren? Frage mich etwas!";
String slotValue = request.getIntent().getSlot(SLOT_NAME).getValue();
if (slotValue != null) {
String slot = "Kontostand";
if (slot.equals(slotValue)) {
speechText = "Dein " + slot + " beträgt " + account.getBalance();
}
slot = "Kontonummer";
if (slot.equals(slotValue)) {
speechText = "Deine " + slot + " lautet " + account.getNumber();
}
slot = "IBAN";
if (slot.equals(slotValue)) {
speechText = "Deine " + slot + " lautet " + account.getIban();
}
slot = "Eröffnungsdatum";
if (slot.equals(slotValue)) {
speechText = "Dein " + slot + " war " + account.getOpeningDate();
}
slot = "Abhebegebühr";
if (slot.equals(slotValue)) {
speechText = "Deine " + slot + " beträgt " + account.getWithdrawalFee();
}
slot = "Zinssatz";
if (slot.equals(slotValue)) {
speechText = "Dein " + slot + " ist aktuell " + account.getInterestRate();
}
slot = "Kreditlimit";
if (slot.equals(slotValue)) {
speechText = "Dein " + slot + " ist " + account.getCreditLimit();
}
slot = "Kreditkartenlimit";
if (slot.equals(slotValue)) {
speechText = "Dein " + slot + " beträgt " + account.getCreditcardLimit();
}
return getSpeechletResponse(speechText);
} else {
return getSpeechletResponse(repromptText);
}
}
use of com.amazon.speech.speechlet.IntentRequest in project amos-ss17-alexa by c-i-ber.
the class BlockCardService method onIntent.
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
IntentRequest request = requestEnvelope.getRequest();
Session session = requestEnvelope.getSession();
// TODO: Use account later to actually block a card
Account account = AccountFactory.getInstance().getAccount(number);
if (request.getIntent().getName().equals("AMAZON.YesIntent")) {
String cardNumberObj = (String) session.getAttribute("BlockCardService.CardNumber");
if (cardNumberObj != null) {
long cardNumber = Long.parseLong(cardNumberObj);
return getSpeechletResponse("Karte " + cardNumberObj + " wurde gesperrt.", "", false);
}
return null;
} else if (request.getIntent().getName().equals("AMAZON.NoIntent")) {
session.setAttribute("BlockCardService.CardNumber", null);
return getSpeechletResponse("Okay, tschüss.", "", false);
} else {
String bankCardNumber = request.getIntent().getSlot("BankCardNumber").getValue();
if (bankCardNumber == null) {
String speechText = "Wie lautet die Nummber der Karte?";
String repromptText = "Sagen Sie auch die Nummer der Karte. Zum Beispiel: Sperre Karte 12345.";
return getSpeechletResponse(speechText, repromptText, false);
} else {
session.setAttribute("BlockCardService.CardNumber", bankCardNumber);
String speechText = "Möchten Sie die Karte " + bankCardNumber + " wirklich sperren?";
String repromptText = "Bitte bestätigen Sie, indem Sie 'ja' sagen.";
return getSpeechletResponse(speechText, repromptText, true);
}
}
}
use of com.amazon.speech.speechlet.IntentRequest in project amos-ss17-alexa by c-i-ber.
the class AmosAlexaSpeechletTest method getEnvelope.
private SpeechletRequestEnvelope<IntentRequest> getEnvelope(String intent, String... slots) throws IOException, NoSuchFieldException, IllegalAccessException {
SpeechletRequestEnvelope<IntentRequest> envelope = (SpeechletRequestEnvelope<IntentRequest>) SpeechletRequestEnvelope.fromJson(buildJson(intent, slots));
// Set session via reflection
Field f1 = envelope.getClass().getDeclaredField("session");
f1.setAccessible(true);
f1.set(envelope, session);
return envelope;
}
Aggregations