Search in sources :

Example 1 with Intent

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

the class BankContactService method onIntent.

@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
    IntentRequest intentRequest = requestEnvelope.getRequest();
    Intent intent = intentRequest.getIntent();
    String intentName = getIntentName(intent);
    // slot values
    slotBankNameValue = intent.getSlot(SLOT_BANK_NAME) != null ? intent.getSlot(SLOT_BANK_NAME).getValue() : null;
    slotDateValue = intent.getSlot(SLOT_NAME_OPENING_HOURS_DATE) != null ? intent.getSlot(SLOT_NAME_OPENING_HOURS_DATE).getValue() : null;
    if (slotBankNameValue == null) {
        slotBankNameValue = SLOT_NAME_BANK_FALLBACK;
    }
    log.info(getClass().getCanonicalName() + "Slot Value : " + slotBankNameValue + " ( " + SLOT_BANK_NAME + " ) ");
    log.info(getClass().getCanonicalName() + "Slot Value : " + slotDateValue + " ( " + SLOT_NAME_OPENING_HOURS_DATE + " ) ");
    /*
        // Authenticate
        if (!AuthenticationManager.isAuthenticated()) {
            return AuthenticationManager.authenticate();
        }

        AuthenticationManager.revokeAuthentication();
        */
    // try to get device address - needs user permission and real device
    DeviceAddressUtil.getDeviceAddress(requestEnvelope);
    // check permission for device address
    if (consentToken == null) {
        log.info("Consent token is null. Ask for permission!");
    // simulation environment does not support permission requests
    // return getPermissionsResponse();
    }
    switch(intentName) {
        case BANK_ADDRESS_INTENT:
            return bankAddressResponse();
        case BANK_OPENING_HOURS_INTENT:
            return bankOpeningHoursResponse();
        case "AMAZON.HelpIntent":
            return getAskResponse(BANK_CONTACT_CARD, HELP_TEXT);
        default:
            return getAskResponse(BANK_CONTACT_CARD, UNHANDLED_TEXT);
    }
}
Also used : Intent(com.amazon.speech.slu.Intent)

Example 2 with Intent

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

the class PriceQueryService method onIntent.

@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
    IntentRequest request = requestEnvelope.getRequest();
    Session session = requestEnvelope.getSession();
    log.info("onIntent requestId={}, sessionId={}", request.getRequestId(), session.getSessionId());
    Intent intent = request.getIntent();
    String intentName = (intent != null) ? intent.getName() : null;
    log.warn(getClass().toString() + " Intent started: " + intentName);
    if ("ProductRequestIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getProductInformation(intent, session);
    } else if ("MicrosoftStockIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getMicrosoftStock(intent, session);
    } else if ("AppleStockIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getAppleStock(intent, session);
    } else if ("TeslaStockIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getTeslaStock(intent, session);
    } else if ("DepotRequestIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getDepotInformation(intent, session);
    } else if ("DepotCompositionIntent".equals(intentName)) {
        log.warn(getClass().toString() + " Intent started: " + intentName);
        return getDepotComposition(intent, session);
    }
    return null;
}
Also used : Intent(com.amazon.speech.slu.Intent)

Example 3 with Intent

use of com.amazon.speech.slu.Intent 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("Authenticated: " + AuthenticationManager.isAuthenticated());
    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());
    if ("AMAZON.HelpIntent".equals(intentName)) {
        return getHelpResponse();
    } else if ("GetAccountBalance".equals(intentName)) {
        return getAccountBalanceResponse();
    } else if ("checkCreditLimit".equals(intentName)) {
        return getCreditLimitResponse();
    } else if ("bankTransfer".equals(intentName)) {
        return bankTransfer(intent.getSlots());
    } else if ("TestListIntent".equals(intentName)) {
        // Set CURRENTDIALOG to start the TestList dialog
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "TestList");
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("ReplacementCardIntent".equals(intentName)) {
        // Set CURRENTDIALOG to start the ReplacementCard dialog
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "ReplacementCard");
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("ReplacementCardReasonIntent".equals(intentName)) {
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("SavingsPlanIntent".equals(intentName)) {
        // Set CURRENTDIALOG to start the SavingsPlan dialog
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "SavingsPlan");
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("FourDigitNumberIntent".equals(intentName)) {
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("MicrosoftStockIntent".equals(intentName)) {
        return DummyDepot.getMicrosoftStock(intent, session);
    } else if ("AppleStockIntent".equals(intentName)) {
        return DummyDepot.getAppleStock(intent, session);
    } else if ("TeslaStockIntent".equals(intentName)) {
        return DummyDepot.getTeslaStock(intent, session);
    } else if ("DepotRequestIntent".equals(intentName)) {
        return DummyDepot.getDepotInformation(intent, session);
    } else if ("DepotCompositionIntent".equals(intentName)) {
        return DummyDepot.getDepotComposition(intent, session);
    } else if ("StandingOrdersInfoIntent".equals(intentName)) {
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "StandingOrders");
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("StandingOrdersDeleteIntent".equals(intentName)) {
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "StandingOrders");
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("StandingOrdersModifyIntent".equals(intentName)) {
        sessionStorage.put(SessionStorage.CURRENTDIALOG, "StandingOrders");
        // Let the DialogHandler handle this intent
        return DialogResponseManager.getInstance().handle(intent, sessionStorage);
    } else if ("AMAZON.YesIntent".equals(intentName)) {
        // Let the DialogHandler handle this intent
        SpeechletResponse response = DialogResponseManager.getInstance().handle(intent, sessionStorage);
        if (response != null) {
            return response;
        }
    } else if ("AMAZON.NoIntent".equals(intentName)) {
        // Let the DialogHandler handle this intent
        SpeechletResponse response = DialogResponseManager.getInstance().handle(intent, sessionStorage);
        if (response != null) {
            return response;
        }
    }
    SpeechletResponse response = notifyOnIntent(requestEnvelope);
    if (response == null) {
        PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
        speech.setText("Ein Fehler ist aufgetreten.");
        return SpeechletResponse.newTellResponse(speech);
    }
    return response;
}
Also used : Intent(com.amazon.speech.slu.Intent) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Example 4 with Intent

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

the class AuthenticationManager method onIntent.

@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
    Intent intent = requestEnvelope.getRequest().getIntent();
    String userPIN = intent.getSlot(SLOT_AUTH_PIN) != null ? intent.getSlot(SLOT_AUTH_PIN).getValue() : "";
    if (!userPIN.equals(secretPIN)) {
        log.info("PIN wrong! User: " + userPIN + " Actual: " + secretPIN);
        return getAskResponse(AUTHENTICATION_CARD, INCORRECT_MESSAGE);
    }
    log.info("PIN was correct");
    SessionStorage.getInstance().putObject(AUTHENTICATION_SESSION, AUTHENTICATION_ATTRIBUTE, Boolean.TRUE);
    return getResponse(AUTHENTICATION_CARD, CORRECT_MESSAGE);
}
Also used : Intent(com.amazon.speech.slu.Intent)

Aggregations

Intent (com.amazon.speech.slu.Intent)4 PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)1