alexa-skills-kitalexa-voice-service

How to record and change the volume in an Alexa skill?


I'm currently working on developing my first Alexa skill in Node.js using the developer console. The idea is conceptually simple.

  1. Record the current volume of the alexa system (whether an echo or pop etc..)
  2. Set the volume to 10
  3. Play a notification
  4. Set the volume back to the previous state

While I can do something similar using the Alexa Routines, it doesn't allow me to return to the original volume, thus wanting to write a skill to do so.

I'm currently struggling to work out how to get the current volume and have been looking through the docs and not found any help. Alexa.Speaker may be what I'm looking for, but I don't know how to access it through my Custom Skill.

My questions are:

How do I get the volume of the device the Alexa command is being called on?

How do I set the volume of the device the Alexa device the command is being called on?

var currentVolume = 5;
const RingEchoDevicesHandler = {
canHandle(handlerInput) {
    return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
        && Alexa.getIntentName(handlerInput.requestEnvelope) === 'RingEchoDevices';
},
handle(handlerInput) {
    currentVolume = // Get Echo Dot's volume
    * Set echo dot's volume to 10
    const speakOutput = 'Hello World!';

    return handlerInput.responseBuilder
        .speak(speakOutput)
        .getResponse();
}

};

Thanks for any help.


Solution

  • I would press the pause button on your skill development.

    You cannot gain access to volume settings etc via custom skills.

    In fact I can't think of a way of doing what you're asking for, you can only ask Alexa what volume setting is current. You can't access that value in routines or in custom skills.

    So a rethink is in order I believe.