Search in sources :

Example 11 with PlainTextOutputSpeech

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

the class SavingsPlanDialog method cancelAction.

private SpeechletResponse cancelAction() {
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText("OK tschuess!");
    return SpeechletResponse.newTellResponse(speech);
}
Also used : PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 12 with PlainTextOutputSpeech

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

the class StandingOrderService method getStandingOrderKeywordResultsInfo.

private SpeechletResponse getStandingOrderKeywordResultsInfo(Session session) {
    session.setAttribute(DIALOG_CONTEXT, "StandingOrderInfo");
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i <= 1; i++) {
        builder.append(standingOrders.get(i).getSpeechOutput());
    }
    if (standingOrders.size() > 2) {
        return askForFurtherStandingOrderEntry(session, builder, 2);
    } else {
        builder.append("Das waren alle vorhandenen Dauerauftraege. ");
        PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
        speech.setText(builder.toString());
        return SpeechletResponse.newTellResponse(speech);
    }
}
Also used : PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 13 with PlainTextOutputSpeech

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

the class StandingOrderService method getStandingOrdersModifyResponse.

private SpeechletResponse getStandingOrdersModifyResponse(Intent intent, Session session) {
    String standingOrderToModify = (String) session.getAttribute("StandingOrderToModify");
    String newAmount = (String) session.getAttribute("NewAmount");
    // TODO never used
    String newExecutionRate = (String) session.getAttribute("NewExecutionRate");
    String newFirstExecution = (String) session.getAttribute("NewFirstExecution");
    ObjectMapper mapper = new ObjectMapper();
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Ändere Dauerauftrag");
    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    Number standingOrderNum = Integer.parseInt(standingOrderToModify);
    StandingOrder standingOrder = AccountAPI.getStandingOrder(ACCOUNT_NUMBER, standingOrderNum);
    // TODO: Actually update the StandingOrder
    standingOrder.setAmount(Integer.parseInt(newAmount));
    AccountAPI.updateStandingOrder(ACCOUNT_NUMBER, standingOrder);
    card.setContent("Dauerauftrag Nummer " + standingOrderToModify + " wurde geändert.");
    speech.setText("Dauerauftrag Nummer " + standingOrderToModify + " wurde geaendert.");
    return SpeechletResponse.newTellResponse(speech, card);
}
Also used : StandingOrder(model.banking.StandingOrder) SimpleCard(com.amazon.speech.ui.SimpleCard) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with PlainTextOutputSpeech

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

the class StandingOrderService method askForModificationConfirmation.

private SpeechletResponse askForModificationConfirmation(Intent intent, Session session) {
    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");
    if (numberSlot.getValue() == null || (amountSlot.getValue() == null && executionRateSlot.getValue() == null && firstExecutionSlot.getValue() == null)) {
        String text = "Das habe ich nicht ganz verstanden. Bitte wiederhole deine Eingabe.";
        return getAskResponse(STANDING_ORDERS, text);
    }
    session.setAttribute("StandingOrderToModify", numberSlot.getValue());
    session.setAttribute("NewAmount", amountSlot.getValue());
    session.setAttribute("NewExecutionRate", executionRateSlot.getValue());
    session.setAttribute("NewFirstExecution", firstExecutionSlot.getValue());
    // Create the plain text output
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText("Soll ich den Betrag von Dauerauftrag Nummer " + numberSlot.getValue() + " wirklich auf " + amountSlot.getValue() + " Euro aendern?");
    // 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) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 15 with PlainTextOutputSpeech

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

the class ReplacementCardService method askForCardNumber.

private SpeechletResponse askForCardNumber(Session session, boolean errored) {
    // TODO: Load account from session
    Collection<Card> cards = AccountAPI.getCardsForAccount(ACCOUNT_NUMBER);
    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<Card> userCards = new ArrayList<>();
        for (Card card : cards) {
            // Check if this card is active
            if (card.getStatus() != Card.Status.ACTIVE) {
                continue;
            }
            userCards.add(card);
            String prefix = (card.getCardType() == Card.CardType.CREDIT ? "Kredit" : "EC-");
            stringBuilder.append(prefix + "karte mit den Endziffern <say-as interpret-as=\"digits\">" + card.getCardNumber().substring(card.getCardNumber().length() - 4) + "</say-as>. ");
        }
        // Store all card numbers in the session
        SessionStorage.getInstance().getStorage(session.getSessionId()).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 : ArrayList(java.util.ArrayList) Reprompt(com.amazon.speech.ui.Reprompt) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech) SsmlOutputSpeech(com.amazon.speech.ui.SsmlOutputSpeech) Card(model.banking.Card)

Aggregations

PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)44 Reprompt (com.amazon.speech.ui.Reprompt)22 SimpleCard (com.amazon.speech.ui.SimpleCard)18 Slot (com.amazon.speech.slu.Slot)8 ArrayList (java.util.ArrayList)4 StandingOrder (model.banking.StandingOrder)4 JSONException (com.amazonaws.util.json.JSONException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ApiHelper (amosalexa.ApiHelper)2 SpeechletException (com.amazon.speech.speechlet.SpeechletException)2 SsmlOutputSpeech (com.amazon.speech.ui.SsmlOutputSpeech)2 IOException (java.io.IOException)2 List (java.util.List)2 Card (model.banking.Card)2 StandingOrder (model.banking.account.StandingOrder)2 BankingRESTClient (api.BankingRESTClient)1 Intent (com.amazon.speech.slu.Intent)1 AskForPermissionsConsentCard (com.amazon.speech.ui.AskForPermissionsConsentCard)1 JSONObject (com.amazonaws.util.json.JSONObject)1 DateFormat (java.text.DateFormat)1