use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class StandingOrderService method askForDDeletionConfirmation.
private SpeechletResponse askForDDeletionConfirmation(Intent intent, Session session) {
Map<String, Slot> slots = intent.getSlots();
Slot numberSlot = slots.get("Number");
LOGGER.info("NumberSlot: " + numberSlot.getValue());
session.setAttribute("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.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class StandingOrderService 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, Session session) {
LOGGER.info("StandingOrdersResponse called.");
Map<String, Slot> slots = intent.getSlots();
Collection<StandingOrder> standingOrdersCollection = AccountAPI.getStandingOrdersForAccount(ACCOUNT_NUMBER);
// Create the Simple card content.
SimpleCard card = new SimpleCard();
card.setTitle("Daueraufträge");
// Create the plain text output.
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
if (standingOrdersCollection == null || standingOrdersCollection.isEmpty()) {
card.setContent("Keine Daueraufträge vorhanden.");
speech.setText("Keine Dauerauftraege vorhanden.");
return SpeechletResponse.newTellResponse(speech, card);
}
standingOrders = new ArrayList<>(standingOrdersCollection);
// 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().toLowerCase().replace(" ", "").equals("email");
StringBuilder builder = new StringBuilder();
if (sendPerEmail) {
StringBuilder standingOrderMailBody = new StringBuilder();
for (StandingOrder so : standingOrders) {
standingOrderMailBody.append(so.getSpeechOutput() + "\n");
}
EMailClient.SendEMail("Daueraufträge", standingOrderMailBody.toString());
builder.append("Ich habe eine Übersicht deiner ").append(standingOrders.size()).append(" Daueraufträge an deine E-Mail-Adresse gesendet.");
} else {
// We want to directly return standing orders here
Slot payeeSlot = slots.get("Payee");
String payee = (payeeSlot == null ? null : payeeSlot.getValue());
if (payee != null) {
// User specified a recipient
standingOrders.clear();
// Find closest standing orders that could match the request.
for (int i = 0; i < standingOrders.size(); i++) {
if (StringUtils.getLevenshteinDistance(payee, standingOrders.get(i).getPayee()) <= standingOrders.get(i).getPayee().length() / 3) {
standingOrders.add(standingOrders.get(i));
}
}
builder.append(standingOrders.size() == 1 ? "Es wurde ein Dauerauftrag gefunden. " : "Es wurden " + standingOrders.size() + " Dauerauftraege gefunden. ");
for (int i = 0; i <= 1; i++) {
builder.append(standingOrders.get(i).getSpeechOutput());
}
if (standingOrders.size() > 2) {
return askForFurtherStandingOrderEntry(session, builder, 2);
}
} else {
// Just return all standing orders
builder.append("Du hast momentan ").append(standingOrders.size() == 1 ? "einen Dauerauftrag. " : standingOrders.size() + " Dauerauftraege. ");
for (int i = 0; i <= 1; i++) {
builder.append(standingOrders.get(i).getSpeechOutput());
}
if (standingOrders.size() > 2) {
return askForFurtherStandingOrderEntry(session, builder, 2);
}
}
}
String text = builder.toString();
card.setContent(text);
speech.setText(text);
return SpeechletResponse.newTellResponse(speech, card);
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class AmosAlexaSpeechlet method onIntent.
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
IntentRequest request = requestEnvelope.getRequest();
Session session = requestEnvelope.getSession();
LOGGER.info("onIntent requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : "";
SessionStorage.Storage sessionStorage = SessionStorage.getInstance().getStorage(session.getSessionId());
String currentDialogContext = (String) sessionStorage.get(SessionStorage.CURRENTDIALOG);
LOGGER.info("Intent: " + intentName);
LOGGER.info("DialogContext: " + currentDialogContext);
if (intentName.equals(STOP_INTENT)) {
return getResponse("Stop", "");
}
SpeechletResponse response = notifyOnIntent(requestEnvelope);
if (response == null) {
SessionStorage.getInstance().removeStorage(session.getSessionId());
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
// speech.setText("Ein Fehler ist aufgetreten.");
speech.setText("");
return SpeechletResponse.newTellResponse(speech);
}
return response;
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class BankContactService method getPermissionsResponse.
/**
* Creates a {@code SpeechletResponse} for permission requests.
*
* @return SpeechletResponse spoken and visual response for the given intent
*/
private SpeechletResponse getPermissionsResponse() {
String speechText = "Dieser Skill hat keine Berechtigung auf deine Adresse " + "Gib bitte diesem Skill die Berechtigung auf deine Adresse zu zugreifen";
AskForPermissionsConsentCard card = new AskForPermissionsConsentCard();
card.setTitle(BANK_CONTACT_CARD);
Set<String> permissions = new HashSet<>();
permissions.add(ALL_ADDRESS_PERMISSION);
card.setPermissions(permissions);
PlainTextOutputSpeech speech = getPlainTextOutputSpeech(speechText);
return SpeechletResponse.newTellResponse(speech, card);
}
use of com.amazon.speech.ui.PlainTextOutputSpeech in project amos-ss17-alexa by c-i-ber.
the class ReplacementCardService method cancelDialog.
private SpeechletResponse cancelDialog() {
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("");
return SpeechletResponse.newTellResponse(speech);
}
Aggregations