use of com.amazon.speech.slu.Slot in project amos-ss17-alexa by c-i-ber.
the class StandingOrderDialog method askForDDeletionConfirmation.
private SpeechletResponse askForDDeletionConfirmation(Intent intent, SessionStorage.Storage storage) {
Map<String, Slot> slots = intent.getSlots();
Slot numberSlot = slots.get("Number");
LOGGER.info("NumberSlot: " + numberSlot.getValue());
storage.put("StandingOrderToDelete", numberSlot.getValue());
// Create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Moechtest du den Dauerauftrag mit der Nummer " + numberSlot.getValue() + " wirklich loeschen?");
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
use of com.amazon.speech.slu.Slot in project amos-ss17-alexa by c-i-ber.
the class StandingOrderDialog method askForModificationConfirmation.
private SpeechletResponse askForModificationConfirmation(Intent intent, SessionStorage.Storage storage) {
Map<String, Slot> slots = intent.getSlots();
Slot numberSlot = slots.get("Number");
Slot amountSlot = slots.get("Amount");
Slot executionRateSlot = slots.get("ExecutionRate");
Slot firstExecutionSlot = slots.get("FirstExecution");
storage.put("StandingOrderToModify", numberSlot.getValue());
storage.put("NewAmount", amountSlot.getValue());
storage.put("NewExecutionRate", executionRateSlot.getValue());
storage.put("NewFirstExecution", firstExecutionSlot.getValue());
// Create the plain text output
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Moechtest du den Dauerauftrag mit der Nummer " + numberSlot.getValue() + " wirklich aendern?");
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
use of com.amazon.speech.slu.Slot in project amos-ss17-alexa by c-i-ber.
the class StandingOrderDialog method getStandingOrdersInfoResponse.
/**
* Creates a {@code SpeechletResponse} for the standing orders intent.
*
* @return SpeechletResponse spoken and visual response for the given intent
*/
private SpeechletResponse getStandingOrdersInfoResponse(Intent intent, SessionStorage.Storage storage) {
LOGGER.info("StandingOrdersResponse called.");
Map<String, Slot> slots = intent.getSlots();
ObjectMapper mapper = new ObjectMapper();
ApiHelper helper = new ApiHelper();
String test = null;
try {
test = helper.sendGet("http://amos-bank-lb-723794096.eu-central-1.elb.amazonaws.com/api/v1_0/accounts/9999999999/standingorders");
} catch (Exception e) {
//TODO
}
StandingOrderResponse standingOrderResponse = null;
try {
standingOrderResponse = mapper.readValue(test, StandingOrderResponse.class);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
// Create the Simple card content.
SimpleCard card = new SimpleCard();
card.setTitle("Daueraufträge");
// Create the plain text output.
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
if (standingOrderResponse == null || standingOrderResponse.get_embedded() == null) {
card.setContent("Keine Daueraufträge vorhanden.");
speech.setText("Keine Dauerauftraege vorhanden.");
return SpeechletResponse.newTellResponse(speech, card);
}
standingOrders = standingOrderResponse.get_embedded().getStandingOrders();
// Check if user requested to have their stranding orders sent to their email address
Slot channelSlot = slots.get("Channel");
boolean sendPerEmail = channelSlot != null && channelSlot.getValue() != null && channelSlot.getValue().equals("email");
StringBuilder textBuilder = new StringBuilder();
if (sendPerEmail) {
// TODO: Send standing orders to user's email address
textBuilder.append("Ich habe").append(standingOrders.length).append(" an deine E-Mail-Adresse gesendet.");
} else {
// We want to directly return standing orders here
Slot payeeSlot = slots.get("Payee");
String payee = payeeSlot.getValue();
if (payee != null) {
// User specified a recipient
List<StandingOrder> orders = new LinkedList<>();
// Find closest standing orders that could match the request.
for (int i = 0; i < standingOrders.length; i++) {
if (StringUtils.getLevenshteinDistance(payee, standingOrders[i].getPayee()) <= standingOrders[i].getPayee().length() / 3) {
orders.add(standingOrders[i]);
}
}
textBuilder.append(orders.size() == 1 ? "Es wurde ein Dauerauftrag gefunden." : "Es wurden " + orders.size() + " Dauerauftraege gefunden.");
int i = 1;
for (StandingOrder order : orders) {
textBuilder.append(' ');
textBuilder.append("Dauerauftrag ").append(order.getStandingOrderId()).append(": ");
textBuilder.append("Ueberweise ").append(order.getExecutionRateString()).append(order.getAmount()).append(" Euro an ").append(order.getPayee()).append(".");
i++;
}
} else {
// Just return all standing orders
textBuilder.append("Du hast momentan ").append(standingOrders.length == 1 ? "einen Dauerauftrag. " : standingOrders.length + " Dauerauftraege. ");
for (int i = 0; i <= 1; i++) {
textBuilder.append(' ');
textBuilder.append("Dauerauftrag ").append(standingOrders[i].getStandingOrderId()).append(": ");
textBuilder.append("Ueberweise ").append(standingOrders[i].getExecutionRateString()).append(standingOrders[i].getAmount()).append(" Euro an ").append(standingOrders[i].getPayee()).append(".");
}
if (standingOrders.length > 2) {
textBuilder.append(" Moechtest du einen weiteren Eintrag hoeren?");
String text = textBuilder.toString();
card.setContent(text);
speech.setText(text);
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
// Save current list offset in this session
storage.put("NextStandingOrder", 2);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
}
}
String text = textBuilder.toString();
card.setContent(text);
speech.setText(text);
return SpeechletResponse.newTellResponse(speech, card);
}
use of com.amazon.speech.slu.Slot in project amos-ss17-alexa by c-i-ber.
the class PriceQueryService method getProductInformation.
private SpeechletResponse getProductInformation(Intent intent, Session session) {
// get keyword for product search
Slot slot = intent.getSlot("ProductKeyword");
String keyword = slot.getValue();
String speechTextStart = "";
String speechText;
if (keyword != null) {
log.warn(getClass().toString() + " Keyword: " + keyword);
List<Item> items = AWSLookup.itemSearch(keyword, 1, null);
if (!items.isEmpty()) {
speechTextStart = "Bingo, Ich habe etwas gefunden!";
}
String specheTextItems = "";
for (int i = 0; i < 3; i++) {
Offer offer = AWSLookup.offerLookup(items.get(i).getASIN());
specheTextItems = specheTextItems + AWSUtil.shortTitle(items.get(i).getTitle()) + "fuer " + offer.getLowestNewPrice() / 100 + " Euro";
}
speechText = speechTextStart + specheTextItems;
} else {
speechText = speechTextWelcome;
}
return getSpeechletResponse(speechText, repromptTextWelcome);
}
use of com.amazon.speech.slu.Slot in project amos-ss17-alexa by c-i-ber.
the class SavingsPlanDialog method askForSavingsParameter.
private SpeechletResponse askForSavingsParameter(Intent intent, SessionStorage.Storage storage) {
Map<String, Slot> slots = intent.getSlots();
String grundbetrag = slots.get(GRUNDBETRAG_KEY).getValue();
String anzahlJahre = slots.get(ANZAHL_JAHRE_KEY).getValue();
String monatlicheEinzahlung = slots.get(EINZAHLUNG_MONAT_KEY).getValue();
String speechText, repromptText;
LOGGER.info("Grundbetrag: " + grundbetrag);
LOGGER.info("Jahre: " + anzahlJahre);
LOGGER.info("monatliche Einzahlung: " + monatlicheEinzahlung);
LOGGER.info("Storage Before: " + storage);
if (grundbetrag != null && storage.containsKey(GRUNDBETRAG_KEY)) {
monatlicheEinzahlung = grundbetrag;
grundbetrag = null;
}
if (grundbetrag != null) {
storage.put(GRUNDBETRAG_KEY, grundbetrag);
}
if (anzahlJahre != null) {
storage.put(ANZAHL_JAHRE_KEY, anzahlJahre);
}
if (monatlicheEinzahlung != null) {
storage.put(EINZAHLUNG_MONAT_KEY, monatlicheEinzahlung);
}
if (grundbetrag == null && !storage.containsKey(GRUNDBETRAG_KEY)) {
speechText = "Was moechtest du als Grundbetrag anlegen?";
repromptText = speechText;
return getSpeechletResponse(speechText, repromptText, true);
}
if (anzahlJahre == null && !storage.containsKey(ANZAHL_JAHRE_KEY)) {
speechText = "Wie viele Jahre moechtest du das Geld anlegen?";
//TODO better use duration?
repromptText = speechText;
return getSpeechletResponse(speechText, repromptText, true);
}
if (monatlicheEinzahlung == null && !storage.containsKey(EINZAHLUNG_MONAT_KEY)) {
if (grundbetrag == null && !storage.containsKey(GRUNDBETRAG_KEY)) {
speechText = "Du musst zuerst einen Grundbetrag angeben.";
repromptText = speechText;
return getSpeechletResponse(speechText, repromptText, true);
}
speechText = "Wie viel Geld moechtest du monatlich investieren?";
repromptText = speechText;
return getSpeechletResponse(speechText, repromptText, true);
}
String grundbetragString = (String) storage.get(GRUNDBETRAG_KEY);
String einzahlungMonatString = (String) storage.get(EINZAHLUNG_MONAT_KEY);
String anzahlJahreString = (String) storage.get(ANZAHL_JAHRE_KEY);
String calculationString = calculateSavings(grundbetragString, einzahlungMonatString, anzahlJahreString);
SsmlOutputSpeech speech = new SsmlOutputSpeech();
speech.setSsml("<speak>Bei einem Zinssatz von zwei Prozent waere der Gesamtsparbetrag am Ende " + "des Zeitraums insgesamt <say-as interpret-as=\"number\">" + calculationString + "</say-as> Euro. Soll ich diesen Sparplan fuer dich anlegen?</speak>");
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
//LOGGER.info("Session Afterwards: " + session.getAttributes());
LOGGER.info("Storage afterwards: " + storage);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
Aggregations