Search in sources :

Example 11 with SimpleCard

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

the class TimeTravelService method onIntent.

@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) throws SpeechletException {
    IntentRequest request = requestEnvelope.getRequest();
    Intent intent = request.getIntent();
    if (intent.getName().equals(FUTURE_INTENT)) {
        // TODO: Insert code that sets up data
        String text = "Natürlich, nichts leichter als das. Bitte anschnallen!";
        SpeechletResponse response = new SpeechletResponse();
        // Back to the future song
        List<Directive> directives = new LinkedList<>();
        PlayDirective directive = new PlayDirective();
        AudioItem audioItem = new AudioItem();
        Stream stream = new Stream();
        stream.setToken("this-is-the-audio-token");
        // temporarily hosted on Julian's server
        stream.setUrl("https://files.bitspark.de/bttf.mp3");
        audioItem.setStream(stream);
        directive.setAudioItem(audioItem);
        directive.setPlayBehavior(PlayBehavior.REPLACE_ALL);
        directives.add(directive);
        response.setDirectives(directives);
        // Card
        SimpleCard simpleCard = new SimpleCard();
        simpleCard.setTitle(CARD_TITLE);
        simpleCard.setContent(text);
        response.setCard(simpleCard);
        // Speech
        response.setOutputSpeech(getSSMLOutputSpeech(text));
        return response;
    } else if (intent.getName().equals(PAST_INTENT)) {
        // Create new demo account
        // AccountFactory accountFactory = AccountFactory.getInstance();
        // Account account = accountFactory.createDemo();
        String text = "<prosody rate=\"fast\">Okay! Es geht wieder zurueck. Halte dich fest!</prosody>";
        SpeechletResponse response = new SpeechletResponse();
        // Back to the future song
        List<Directive> directives = new LinkedList<>();
        PlayDirective directive = new PlayDirective();
        AudioItem audioItem = new AudioItem();
        Stream stream = new Stream();
        stream.setToken("this-is-the-audio-token");
        // temporarily hosted on Julian's server
        stream.setUrl("https://files.bitspark.de/bttf.mp3");
        audioItem.setStream(stream);
        directive.setAudioItem(audioItem);
        directive.setPlayBehavior(PlayBehavior.REPLACE_ALL);
        directives.add(directive);
        response.setDirectives(directives);
        // Card
        SimpleCard simpleCard = new SimpleCard();
        simpleCard.setTitle(CARD_TITLE);
        simpleCard.setContent(text);
        response.setCard(simpleCard);
        // Speech
        response.setOutputSpeech(getSSMLOutputSpeech(text));
        return response;
    }
    // Shouldn't happen
    assert (false);
    return null;
}
Also used : Intent(com.amazon.speech.slu.Intent) AudioItem(com.amazon.speech.speechlet.interfaces.audioplayer.AudioItem) SpeechletResponse(com.amazon.speech.speechlet.SpeechletResponse) PlayDirective(com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective) IntentRequest(com.amazon.speech.speechlet.IntentRequest) SimpleCard(com.amazon.speech.ui.SimpleCard) Stream(com.amazon.speech.speechlet.interfaces.audioplayer.Stream) Directive(com.amazon.speech.speechlet.Directive) PlayDirective(com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective)

Example 12 with SimpleCard

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

the class SavingsPlanDialog method getSpeechletResponse.

private SpeechletResponse getSpeechletResponse(String speechText, String repromptText, boolean isAskResponse) {
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Session");
    card.setContent(speechText);
    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);
    if (isAskResponse) {
        // Create reprompt
        PlainTextOutputSpeech repromptSpeech = new PlainTextOutputSpeech();
        repromptSpeech.setText(repromptText);
        Reprompt reprompt = new Reprompt();
        reprompt.setOutputSpeech(repromptSpeech);
        return SpeechletResponse.newAskResponse(speech, reprompt, card);
    } else {
        return SpeechletResponse.newTellResponse(speech, card);
    }
}
Also used : SimpleCard(com.amazon.speech.ui.SimpleCard) Reprompt(com.amazon.speech.ui.Reprompt) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 13 with SimpleCard

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

the class StandingOrderDialog method getStandingOrdersModifyResponse.

private SpeechletResponse getStandingOrdersModifyResponse(Intent intent, SessionStorage.Storage storage) {
    String standingOrderToModify = (String) storage.get("StandingOrderToModify");
    String newAmount = (String) storage.get("NewAmount");
    String newExecutionRate = (String) storage.get("NewExecutionRate");
    String newFirstExecution = (String) storage.get("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();
    JSONObject jsonObject = new JSONObject();
    try {
        //TODO
        jsonObject.put("payee", "Max Mustermann");
        jsonObject.put("amount", newAmount);
        jsonObject.put("destinationAccount", "DE39100000007777777777");
        jsonObject.put("firstExecution", "2017-06-01");
        jsonObject.put("executionRate", "MONTHLY");
        jsonObject.put("description", "Updated standing Order");
    } catch (JSONException e) {
        LOGGER.error(e.getMessage());
    }
    BankingRESTClient bankingRESTClient = BankingRESTClient.getInstance();
    bankingRESTClient.putBankingModelObject("/api/v1_0/accounts/9999999999/standingorders/" + standingOrderToModify, jsonObject.toString(), StandingOrder.class);
    card.setContent("Dauerauftrag Nummer " + standingOrderToModify + " wurde geändert.");
    speech.setText("Dauerauftrag Nummer " + standingOrderToModify + " wurde geaendert.");
    return SpeechletResponse.newTellResponse(speech, card);
}
Also used : JSONObject(com.amazonaws.util.json.JSONObject) SimpleCard(com.amazon.speech.ui.SimpleCard) JSONException(com.amazonaws.util.json.JSONException) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech) BankingRESTClient(api.BankingRESTClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 14 with SimpleCard

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

the class DummyDepot method getSpeechletResponse.

private static SpeechletResponse getSpeechletResponse(String speechText, String repromptText) {
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Bank Information");
    card.setContent(speechText);
    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);
    return SpeechletResponse.newTellResponse(speech, card);
}
Also used : SimpleCard(com.amazon.speech.ui.SimpleCard) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 15 with SimpleCard

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

the class BlockCardService method getSpeechletResponse.

private SpeechletResponse getSpeechletResponse(String speechText, String repromptText, boolean isAskResponse) {
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Block Bank Card");
    card.setContent(speechText);
    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText(speechText);
    if (isAskResponse) {
        // Create reprompt
        PlainTextOutputSpeech repromptSpeech = new PlainTextOutputSpeech();
        repromptSpeech.setText(repromptText);
        Reprompt reprompt = new Reprompt();
        reprompt.setOutputSpeech(repromptSpeech);
        return SpeechletResponse.newAskResponse(speech, reprompt, card);
    } else {
        return SpeechletResponse.newTellResponse(speech, card);
    }
}
Also used : SimpleCard(com.amazon.speech.ui.SimpleCard) Reprompt(com.amazon.speech.ui.Reprompt) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Aggregations

SimpleCard (com.amazon.speech.ui.SimpleCard)20 PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)18 Reprompt (com.amazon.speech.ui.Reprompt)10 Slot (com.amazon.speech.slu.Slot)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 IOException (java.io.IOException)2 BankingRESTClient (api.BankingRESTClient)1 Intent (com.amazon.speech.slu.Intent)1 Directive (com.amazon.speech.speechlet.Directive)1 IntentRequest (com.amazon.speech.speechlet.IntentRequest)1 SpeechletResponse (com.amazon.speech.speechlet.SpeechletResponse)1 AudioItem (com.amazon.speech.speechlet.interfaces.audioplayer.AudioItem)1 Stream (com.amazon.speech.speechlet.interfaces.audioplayer.Stream)1 PlayDirective (com.amazon.speech.speechlet.interfaces.audioplayer.directive.PlayDirective)1 JSONObject (com.amazonaws.util.json.JSONObject)1 DateFormat (java.text.DateFormat)1