Search in sources :

Example 6 with SsmlOutputSpeech

use of com.amazon.speech.ui.SsmlOutputSpeech in project amos-ss17-alexa by c-i-ber.

the class SavingsPlanService method getCalculatedSavingsPlanInfo.

private SpeechletResponse getCalculatedSavingsPlanInfo(Session session) {
    // Assume we have all parameters now. Get them from the session attributes.
    String grundbetragString = (String) session.getAttribute(BASIC_AMOUNT_KEY);
    String einzahlungMonatString = (String) session.getAttribute(MONTHLY_PAYMENT_KEY);
    String anzahlJahreString = (String) session.getAttribute(DURATION_KEY);
    String calculationString = calculateSavings(grundbetragString, einzahlungMonatString, anzahlJahreString);
    // TODO Get interest rate from account info by API (new field)
    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);
    return SpeechletResponse.newAskResponse(speech, reprompt);
}
Also used : Reprompt(com.amazon.speech.ui.Reprompt) SsmlOutputSpeech(com.amazon.speech.ui.SsmlOutputSpeech)

Example 7 with SsmlOutputSpeech

use of com.amazon.speech.ui.SsmlOutputSpeech in project amos-ss17-alexa by c-i-ber.

the class ReplacementCardDialog method askForCardNumber.

private SpeechletResponse askForCardNumber(SessionStorage.Storage storage, boolean errored) {
    // TODO: Load account from session
    Collection<CardResponse> cards = AccountFactory.getInstance().getCardsForAccount("0000000000");
    if (cards.size() == 0) {
        // This user does not have any cards, ordering a replacement card is impossible.
        PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
        speech.setText("Es wurden keine Kredit- oder EC-Karten gefunden.");
        return SpeechletResponse.newTellResponse(speech);
    } else {
        SsmlOutputSpeech speech = new SsmlOutputSpeech();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<speak>");
        if (errored) {
            stringBuilder.append("Entschuldigung, das habe ich nicht verstanden. ");
        }
        stringBuilder.append("Bestellung einer Ersatzkarte. Es wurden folgende Karten gefunden: ");
        List<String> userCards = new ArrayList<>();
        for (CardResponse card : cards) {
            // Check if this card is active
            if (card.status != CardResponse.Status.ACTIVE) {
                continue;
            }
            userCards.add(card.cardNumber);
            String prefix = (card.cardType == CardResponse.CardType.CREDIT ? "Kredit" : "EC-");
            stringBuilder.append(prefix + "karte mit den Endziffern <say-as interpret-as=\"digits\">" + card.cardNumber.substring(card.cardNumber.length() - 4) + "</say-as>. ");
        }
        // Store all card numbers in the session
        storage.put(STORAGE_VALID_CARDS, userCards);
        stringBuilder.append("Bitte gib die Endziffern der Karte an, für die du Ersatz benötigst.");
        stringBuilder.append("</speak>");
        speech.setSsml(stringBuilder.toString());
        // Create reprompt
        Reprompt reprompt = new Reprompt();
        reprompt.setOutputSpeech(speech);
        return SpeechletResponse.newAskResponse(speech, reprompt);
    }
}
Also used : CardResponse(model.banking.account.CardResponse) ArrayList(java.util.ArrayList) Reprompt(com.amazon.speech.ui.Reprompt) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech) SsmlOutputSpeech(com.amazon.speech.ui.SsmlOutputSpeech)

Example 8 with SsmlOutputSpeech

use of com.amazon.speech.ui.SsmlOutputSpeech in project amos-ss17-alexa by c-i-ber.

the class ReplacementCardDialog method askForConfirmation.

private SpeechletResponse askForConfirmation(Intent intent, SessionStorage.Storage storage) {
    if (!storage.containsKey(STORAGE_SELECTED_CARD)) {
        return askForCardNumber(storage, true);
    }
    String replacementReason = intent.getSlot("ReplacementReason").getValue();
    logger.info("Replacement reason: " + replacementReason);
    if (replacementReason.equals("beschaedigt")) {
        logger.info("Beschädigt");
        storage.put(STORAGE_REASON, ReplacementReason.DAMAGED);
    } else if (replacementReason.equals("gesperrt")) {
        logger.info("Gesperrt");
        storage.put(STORAGE_REASON, ReplacementReason.BLOCKED);
    } else {
        return askIfBlockedOrDamaged(intent, storage);
    }
    SsmlOutputSpeech speech = new SsmlOutputSpeech();
    String reason = storage.get(STORAGE_REASON) == ReplacementReason.DAMAGED ? "beschädigte" : "gesperrte";
    String lastDigits = (String) storage.get(STORAGE_SELECTED_CARD);
    lastDigits = lastDigits.substring(lastDigits.length() - 4);
    speech.setSsml("<speak>Soll ein Ersatz für die " + reason + " Karte mit den Endziffern <say-as interpret-as=\"digits\">" + lastDigits + "</say-as> bestellt werden?</speak>");
    // Create reprompt
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(speech);
    return SpeechletResponse.newAskResponse(speech, reprompt);
}
Also used : Reprompt(com.amazon.speech.ui.Reprompt) SsmlOutputSpeech(com.amazon.speech.ui.SsmlOutputSpeech)

Example 9 with SsmlOutputSpeech

use of com.amazon.speech.ui.SsmlOutputSpeech in project amos-ss17-alexa by c-i-ber.

the class StandingOrderService method getCorrectionResponse.

/**
 * Creates a {@code SpeechletResponse} that asks the user if he wants to correct his previous input.
 * Should be called after an Amazon.NoIntent
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
private SpeechletResponse getCorrectionResponse(Intent intent, Session session) {
    String dialogContext = (String) session.getAttribute(DIALOG_CONTEXT);
    LOGGER.info("Context: " + dialogContext);
    Map<String, Slot> slots = intent.getSlots();
    LOGGER.info("Slots: " + slots);
    String standingOrderToModify = (String) session.getAttribute("StandingOrderToModify");
    // Default
    String answer = "Okay, bitte wiederhole die Anweisung oder breche den Vorgang ab, indem du \"Alexa, Stop!\" sagst.";
    if (dialogContext.equals("StandingOrderDeletion")) {
        answer = "Okay, sage die Nummer des Dauerauftrags, den du stattdessen loeschen willst oder " + "breche den Vorgang ab, indem du \"Alexa, Stop!\" sagst.";
    } else if (dialogContext.equals("StandingOrderModification")) {
        answer = "Okay, den Betrag, auf den du Dauerauftrag Nummer " + standingOrderToModify + " stattdessen" + " aendern willst, wiederhole die gesamte Aenderungsanweisung oder breche den Vorgang ab, indem du" + " \"Alexa, Stop!\" sagst.";
    }
    answer = "<speak>\n" + "    <emphasis level=\"reduced\">" + answer + "</emphasis> \n" + "</speak>";
    SsmlOutputSpeech speech = new SsmlOutputSpeech();
    speech.setSsml(answer);
    // Create reprompt
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(speech);
    return SpeechletResponse.newAskResponse(speech, reprompt);
}
Also used : Reprompt(com.amazon.speech.ui.Reprompt) Slot(com.amazon.speech.slu.Slot) SsmlOutputSpeech(com.amazon.speech.ui.SsmlOutputSpeech)

Aggregations

Reprompt (com.amazon.speech.ui.Reprompt)9 SsmlOutputSpeech (com.amazon.speech.ui.SsmlOutputSpeech)9 Slot (com.amazon.speech.slu.Slot)3 PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)2 ArrayList (java.util.ArrayList)2 Card (model.banking.Card)1 StandingOrder (model.banking.StandingOrder)1 CardResponse (model.banking.account.CardResponse)1 Contact (model.db.Contact)1