Recent Posts

Pages: 1 ... 7 8 [9] 10
81
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by jitterjames on August 18, 2022, 06:18:04 PM »
Maybe you can use the two words Jar and Viss ?

I upgraded to node.js 12 and it still seems to be working.
82
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by PegLegTV on August 18, 2022, 01:34:17 PM »
hey jitterjames, nice to here from you too  ;D.

I'll take a look at the script and see what I can figure out.

one big change that I'm not a fan of is that the Invocation name now has to be two words, that will make commands a bit more of a mouth full... Alexa tell iron man lights please, Alexa tell iron man play random episodes of future man

please don't upgrade to test it out, I don't want to break your setup.  :bigno ::saddest

good luck with your home sale and enjoy your long weekend
83
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by jitterjames on August 18, 2022, 01:01:54 PM »
Also, I'm still using node.js version 10.  I'm not sure if I upgrade if it will keep working...
84
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by jitterjames on August 18, 2022, 12:58:59 PM »
Also...

Hi Pegleg.  It's nice to hear from you!  :biglaugh
85
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by jitterjames on August 18, 2022, 12:57:58 PM »
Here is my lambda code.  Note that there are a bunch of environment variables that need to be set or you can just replace them with your own values directly in the code.

Look in the code for process.env.VARNAME

Code: [Select]
/*
****** Pulls speech input and passes on to Voxcommando for custom events *****
*/
var http = require('http');
var Echo_App_ID = "amzn1.ask.skill.3bee3d22-3eb3-4282-4df7-925fc8111b2e"; 

exports.handler = function (event, context) {
    try {
        if (event.session.new) {
            onSessionStarted({requestId: event.request.requestId}, event.session);
        }
        if (event.request.type === "LaunchRequest") {
            onLaunch(event.request,
                     event.session,
                     function callback(sessionAttributes, speechletResponse) {
                        context.succeed(buildResponse(sessionAttributes, speechletResponse));
                     });
        }  else if (event.request.type === "IntentRequest") {
            onIntent(event.request,
                     event.session,
                     function callback(sessionAttributes, speechletResponse) {
                         context.succeed(buildResponse(sessionAttributes, speechletResponse));
                     });
        } else if (event.request.type === "SessionEndedRequest") {
            onSessionEnded(event.request, event.session);
            context.succeed();
        }
    } catch (e) {
        context.fail("Exception: " + e);
    }
};

/**
 * Called when the session starts.
 */
function onSessionStarted(sessionStartedRequest, session) {}

/**
 * Called when the user launches the skill without specifying what they want.
 */
function onLaunch(launchRequest, session, callback) {
    // Dispatch to your skill's launch.
    getWelcomeResponse(callback);
}

/**
 * Called when the user specifies an intent for this skill.
 */
function onIntent(intentRequest, session, callback) {
    var intent = intentRequest.intent,
    intentName = intentRequest.intent.name;
    callEchoToVC(intent, session, callback); // Whatever the Intent is, pass it straight through to VC
}

/**
 * Called when the user ends the session.
 * Is not called when the skill returns shouldEndSession=true.
 */
function onSessionEnded(sessionEndedRequest, session) {
}

// --------------- Main Intent Processing Function ----------------

function callEchoToVC(intent, session, callback)
{
    var sessionAttributes = "{}";
    var cardTitle = "VoxCommando";
    var shouldEndSession = true;

    var payload = "";
    var speechOutput = "error maybe?";
    var repromptText = "...";
    var i = 0;
    var slots = intent.slots;
   
    //Pull the spoken text and format
    var actionSlot = intent.slots.Action;
    var setAction = actionSlot.value.toLowerCase();
   
    if (setAction.endsWith(" only"))
    {
        shouldEndSession=true;
        setAction = setAction.replace(" only","")
       
    }
   
    if(process.env.phrases_cancel.includes(setAction))
    {
        speechOutput ="Cancelling";
        shouldEndSession=true;
        callback(sessionAttributes, buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
        return;
    }
    else if (setAction.length<5)
    {
        speechOutput =process.env.tts_tooshort;
        shouldEndSession=false;
        callback(sessionAttributes, buildSpeechletResponse("Action string too short", speechOutput, repromptText, shouldEndSession));
        return;
    }
    setAction = setAction.replace("1st","first")
    .replace("2nd","second")
    .replace("3rd","third")
    .replace("4th","fourth")
    .replace("5st","fifth")
    .replace("6th","sixth")
    .replace("7th","seventh")
    .replace("8th","eighth")
    .replace("9th","nineth")
    .replace("10th","tenth")
    ;
   
    var setActionURI = require('querystring').escape(setAction);
    var VC_uri = '/api/VC.TriggerEvent&&EchoToVC&&' + setActionURI;
    var get_options = {
            host: process.env.ip,
            port: process.env.port,
            path: VC_uri
        };
    if (process.env.username !== '')
    {
        get_options = {
            host: process.env.ip,
            port: process.env.port,
            path: VC_uri,
            headers: {
                'Authorization': 'Basic ' + new Buffer.from(process.env.username + ':' + process.env.pwd).toString('base64')
            }
        };
    }
 
    // Set up the request
    var get_req = http.request(get_options, function(res) {
        var VC_results = "";
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            VC_results += chunk;
        });
       
        res.on('end', function () {
            //console.log(VC_results);
            cardTitle = VC_results;
            console.log(VC_results);
            if (res.statusCode === 200) {
                //Parse the Body results from VC, if the command was unknown we will repromt
                if(VC_results.indexOf('<Success>False') > -1) {
                    cardTitle = "Vc error: ";
                    speechOutput = "VoxCommando API error: "+setAction;
                    repromptText = "Try again or say cancel.";
                    shouldEndSession=false;
                }
                else
                {
                    var regex = /<WebResponse>([\s\S]*?)</;
                    var reMatches = VC_results.match(regex);
        if (reMatches)
        {
        var speechOutput = reMatches[1];
        }
                    else speechOutput = "I suck";
                }
            }
            callback(sessionAttributes,
                buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession)); //Pass stingResult instead of speechOutput for debugging if needed
        });
    });
    get_req.on('error', function (e) {
        shouldEndSession=true;
        callback(sessionAttributes,
            buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
    });
    get_req.end();   
}

// --------------- WelcomResponse Function ----------------

function getWelcomeResponse(callback) {
    // If we wanted to initialize the session to have some attributes we could add those here.
    var sessionAttributes = {};
    var cardTitle = "Welcome to Echo To Voxcommando";
    var speechOutput = "You see a smaller Jarvis in there.";

    // If the user either does not reply to the welcome message or says something that is not
    // understood, they will be prompted again with this text.
    var repromptText = "Do you speak English?";
    var shouldEndSession = false;
    callback(sessionAttributes,
             buildSpeechletResponse(cardTitle, speechOutput, repromptText, shouldEndSession));
}

// --------------- Helper Functions ----------------

function buildSpeechletResponse(title, output, repromptText, shouldEndSession) {
    return {
        outputSpeech: {
            type: "PlainText",
            text: output
        },
        card: {
            type: "Simple",
            title: "EchoToVoxcommando - " + title,
            content: output
        },
        reprompt: {
            outputSpeech: {
                type: "PlainText",
                text: repromptText
            }
        },
        shouldEndSession: shouldEndSession
    };
}

function buildResponse(sessionAttributes, speechletResponse) {
    return {
        version: "1.0",
        sessionAttributes: sessionAttributes,
        response: speechletResponse
    };
}
86
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by jitterjames on August 18, 2022, 12:44:45 PM »
I am still using Alexa with VoxCommando and it's working.  I'm a bit busy at the moment because we are selling our house and we will be away for a long weekend.

But give me a poke on Tuesday and I'll try to make some time to help you figure this out.
87
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by Kalle on August 18, 2022, 03:10:30 AM »
Yes, long time ago - maybe if James will find some time he can take a look on it.


stay tuned,


Kalle
88
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by PegLegTV on August 18, 2022, 02:41:24 AM »
Hey kalle, it's been awhile.

Thanks for checking.
89
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by Kalle on August 18, 2022, 02:16:23 AM »
Hi PegLeg,


I noticed the same issue and have no idea how to solve it.


Kalle
90
VoxCommando Basics and Core Features / Re: Echo Dot Integration 2018
« Last post by PegLegTV on August 17, 2022, 08:11:58 PM »
hey its been a long time but being that google is doing what it does best and discontinuing services I'm trying to test out the echo skill to see if it still works and how it works. I'm hoping to replace my google/nest minis.

I was going through the tutorial above and for the most part everything was as described with some minor changes (not bad for 3 years later) how ever the big change is that node.js only allows version 12,14 or 16 and none of them fix the problem. but I cant be 100% sure that node.js is the cause. when I use the "test" tab the invocation name works

alexa voice: Hello, I'm this home's automation AI, what can I do for you
json output:

Code: [Select]
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Hello, I'm this home's automation AI, what can I do for you"
},
"card": {
"type": "Simple",
"title": "EchoToVoxcommando - Welcome to Echo To Voxcommando",
"content": "Hello, I'm this home's automation AI, what can I do for you"
},
"reprompt": {
"outputSpeech": {
"type": "PlainText",
"text": "I could not understand, please try again"
}
},
"shouldEndSession": false,
"type": "_DEFAULT_RESPONSE"
},
"sessionAttributes": {}
}
}

but after that any input I use it fails

example:
me: lights please
alex: There was a problem with the requested skill's response

no json output when it fails

through alexa app:
me: alexa tell iron man lights please
alexa voice: There was a problem with the requested skill's response
alexa app:

Code: [Select]
Skill response was marked as failure
Request identifier: amzn1.echo-api.request.........the target lambda application returned a falure response

has anyone had this issue and found how to solve it?
Pages: 1 ... 7 8 [9] 10