use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class ReplacementCardService method askIfBlockedOrDamaged.
private SpeechletResponse askIfBlockedOrDamaged(Intent intent, Session session) {
String fourDigits = intent.getSlot("Number").getValue();
LOGGER.info("Digits: " + fourDigits);
boolean validDigits = false;
// Check if these digits are valid
List<Card> userCards = (List<Card>) SessionStorage.getInstance().getStorage(session.getSessionId()).get(STORAGE_VALID_CARDS);
for (Card card : userCards) {
String cardNumber = card.getCardNumber();
if (cardNumber.substring(cardNumber.length() - 4).equals(fourDigits)) {
// Digits are valid
session.setAttribute(STORAGE_SELECTED_CARD_NUMBER, cardNumber);
session.setAttribute(STORAGE_SELECTED_CARD_ID, card.getCardId());
validDigits = true;
break;
}
}
// If these are invalid digits, ask again
if (!validDigits) {
return askForCardNumber(session, true);
}
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Wurde die Karte gesperrt oder wurde sie beschädigt?");
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class SavingsPlanService method cancelAction.
private SpeechletResponse cancelAction() {
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("OK tschuess!");
return SpeechletResponse.newTellResponse(speech);
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class SecuritiesAccountInformationService method getNextSecuritiesAccountInformation.
private SpeechletResponse getNextSecuritiesAccountInformation(Intent intent, Session session) {
int nextEntry = (int) session.getAttribute("NextSecurity");
Security nextSecurity;
StringBuilder textBuilder = new StringBuilder();
if (nextEntry < securities.size()) {
String stockPrice = FinanceApi.getStockPrice(securities.get(nextEntry));
nextSecurity = securities.get(nextEntry);
textBuilder.append("Wertpapier Nummer ").append(nextSecurity.getSecurityId()).append(": ").append(nextSecurity.getDescription()).append(", " + nextSecurity.getQuantity() + " Stueck, ").append("mit einem momentanen Wert von ").append(stockPrice).append(" Euro. ");
if (nextEntry == (securities.size() - 1)) {
textBuilder.append("Das waren alle Wertpapiere in deinem Depot.");
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText(textBuilder.toString());
return SpeechletResponse.newTellResponse(speech);
} else {
textBuilder.append("Moechtest du einen weiteren Eintrag hoeren?");
}
// Save current list offset in this session
session.setAttribute("NextSecurity", nextEntry + 1);
String text = textBuilder.toString();
// Create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText(text);
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
} else {
// Create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Das waren alle Wertpapiere in deinem Depot.");
return SpeechletResponse.newTellResponse(speech);
}
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class StandingOrderService method getStandingOrdersDeleteResponse.
private SpeechletResponse getStandingOrdersDeleteResponse(Intent intent, Session session) {
LOGGER.info("StandingOrdersDeleteResponse called.");
String standingOrderToDelete = (String) session.getAttribute("StandingOrderToDelete");
// Create the Simple card content.
SimpleCard card = new SimpleCard();
card.setTitle("Lösche Dauerauftrag");
// Create the plain text output.
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
Number standingOrderNum = Integer.parseInt(standingOrderToDelete);
if (!AccountAPI.deleteStandingOrder(ACCOUNT_NUMBER, standingOrderNum)) {
card.setContent("Dauerauftrag Nummer " + standingOrderToDelete + " wurde nicht gefunden.");
speech.setText("Dauerauftrag Nummer " + standingOrderToDelete + " wurde nicht gefunden.");
return SpeechletResponse.newTellResponse(speech, card);
}
card.setContent("Dauerauftrag Nummer " + standingOrderToDelete + " wurde gelöscht.");
speech.setText("Dauerauftrag Nummer " + standingOrderToDelete + " wurde geloescht.");
return SpeechletResponse.newTellResponse(speech, card);
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class StandingOrderService method smartUpdateStandingOrderConfirmation.
/**
* Creates a {@code SpeechletResponse} for the standing orders intent.
*
* @return SpeechletResponse spoken and visual response for the given intent
*/
private SpeechletResponse smartUpdateStandingOrderConfirmation(Intent intent, Session session) {
LOGGER.info("SmartStandingOrders called.");
Map<String, Slot> slots = intent.getSlots();
Collection<StandingOrder> standingOrdersCollection = AccountAPI.getStandingOrdersForAccount(ACCOUNT_NUMBER);
standingOrders = new ArrayList<>(standingOrdersCollection);
SimpleCard card = new SimpleCard();
card.setTitle("Daueraufträge");
Slot payeeSlot = slots.get("Payee");
String payee = (payeeSlot == null ? null : payeeSlot.getValue());
Slot payeeSecondNameSlot = slots.get("PayeeSecondName");
String payeeSecondName = (payeeSecondNameSlot == null ? null : payeeSecondNameSlot.getValue());
Slot amountSlot = slots.get("orderAmount");
String amount = (amountSlot == null ? null : amountSlot.getValue());
String payeeFullName;
if (payee == null) {
payeeFullName = payeeSecondName.toLowerCase();
} else if (payeeSecondName == null) {
payeeFullName = payee.toLowerCase();
} else {
payeeFullName = (payee + " " + payeeSecondName).toLowerCase();
}
LOGGER.info("full name: " + payeeFullName);
session.setAttribute("NewAmount", amount);
session.setAttribute("Payee", payee);
session.setAttribute("PayeeSecondName", payeeSecondName);
for (StandingOrder standingOrder : standingOrders) {
String amountString = Integer.toString(standingOrder.getAmount().intValue());
LOGGER.info(standingOrder.getPayee().toLowerCase() + ": " + payeeFullName);
if (standingOrder.getPayee().toLowerCase().equals(payeeFullName)) {
// getting data object
DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
Date executionDate;
try {
executionDate = dateFormat.parse(standingOrder.getFirstExecution());
} catch (java.text.ParseException e) {
e.printStackTrace();
}
// Create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Der Dauerauftrag für " + payeeFullName + " über " + standingOrder.getAmount() + " Euro existiert schon. Möchtest du diesen aktualisieren");
session.setAttribute("StandingOrderToModify", standingOrder.getStandingOrderId());
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
}
// creating a new stating order if its in contact list
List<Contact> contactList = DynamoDbMapper.getInstance().loadAll(Contact.class);
List<Contact> contacts = new ArrayList<>(contactList);
for (int i = 0; i < contacts.size(); i++) {
LOGGER.info(contacts.get(i).getName().toString().toLowerCase());
if (contacts.get(i).getName().toString().toLowerCase().equals(payeeFullName)) {
StandingOrder standingOrder = new StandingOrder();
standingOrder.setPayee(payeeFullName);
standingOrder.setAmount(Integer.parseInt(amount));
standingOrder.setDestinationAccount(contacts.get(i).getIban());
standingOrder.setFirstExecution("09-09-2017");
standingOrder.setDestinationAccount("DE39100000007777777777");
AccountAPI.createStandingOrderForAccount(ACCOUNT_NUMBER, standingOrder);
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Ich habe den neuen Dauerauftrag für" + payeeFullName + " über " + amount + " Euro erfolgreich eingerichtet");
// deleting attributes
session.removeAttribute("NewAmount");
session.removeAttribute("Payee");
session.removeAttribute("PayeeSecondName");
return SpeechletResponse.newTellResponse(speech, card);
}
}
// Contact not found
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Ich habe " + payeeFullName + " in deiner Kontaktliste nicht gefunden. " + "Du musst ihm erst in der Kontaktliste hinzufügen");
// deleting attributes
session.removeAttribute("NewAmount");
session.removeAttribute("Payee");
session.removeAttribute("PayeeSecondName");
return SpeechletResponse.newTellResponse(speech, card);
}
Aggregations