mattotodd / node-red-contrib-alexa

a node-red node for integration with amazon alexa skills
Apache License 2.0
20 stars 9 forks source link

All intents processed by same flow #14

Closed cerebrate closed 5 years ago

cerebrate commented 7 years ago

I currently have three intents defined for my skill. Trouble is, whichever intent I invoke, either via voice or using the test page for the skill (by which latter means I know that the correct intent is named in the incoming .json), the same one intent is always invoked in node-red, and the other two are ignored.

Any thoughts?

aidanruff commented 7 years ago

Hi

I think that you will need to have a different url for each intent – unless you can extract the intent from the object passed to Node Red by Amazon.

Pete and I actually only use one intent and trap it with https:///echohttps://%3cmyserver%3e/echo

We have up to 15 words trapped by the skill on Amazon which then just recognises the words and passes them across to our Node Red for processing in javascript. Personally, I prefer this as it means that I can do whatever I want with it in Node Red and not touch the Alexa skill on Amazon.

My skill is called ‘house’, so I can say

“alexa, tell the house to turn on the office light and the outside light”

This will extract the phrase “turn on the office light and the outside light” and pass it to node red where I can then strip it apart with a javascript node

This is the code that I use to process the intent before I do anything – it strips out a lot of padding words such as “please”, “the”, “you” etc.

So, something like “alexa tell the house to turn the office light on please” will actually only pass “ turn office light on” to my next node so that I can process the command.

I hope that this helps a bit Regards

Aidan

var doStuff = {payload: msg.payload.length};

switch (msg.payload.request.type) { case "IntentRequest": if (msg.payload.request.intent.name === "inputIntent") { var word = [];

    word[0] = msg.payload.request.intent.slots.wa.value;
    word[1] = msg.payload.request.intent.slots.wb.value;
    word[2] = msg.payload.request.intent.slots.wc.value;
    word[3] = msg.payload.request.intent.slots.wd.value;
    word[4] = msg.payload.request.intent.slots.we.value;
    word[5] = msg.payload.request.intent.slots.wf.value;
    word[6] = msg.payload.request.intent.slots.wg.value;
    word[7] = msg.payload.request.intent.slots.wh.value;
    word[8] = msg.payload.request.intent.slots.wi.value;
    word[9] = msg.payload.request.intent.slots.wj.value;
    word[10] = msg.payload.request.intent.slots.wk.value;
    word[11] = msg.payload.request.intent.slots.wl.value;
    word[12] = msg.payload.request.intent.slots.wm.value;
    word[13] = msg.payload.request.intent.slots.wn.value;
    word[14] = msg.payload.request.intent.slots.wo.value;

    var thisone = 0, processed = 0, total = word.length;

    for (;;)
        {
        var nxt = "";

        switch (word[thisone])
            {
            case undefined:
            case "the":
            case "to":
            case "thanks":
            case "thank":
            case "please":
            case "you":
            case "er":
            case "erm":
            case "a":
            case "turn":
            case "what's":
            case "what":
            case "is":
            word.splice(thisone,1);
            break;

            default:
            ++thisone;
            break;
            }

        if (++processed >= total)
            break;
        }

    msg.topic = "";
    msg.payload = "OK";
    doStuff.word = word;
    msg.word = word;

    }
return [msg, null];

case "LaunchRequest":
msg.payload = "You need help";
return [null, msg];

case "SessionEndedRequest":
msg.payload = "Session Ended";
return [null, msg];

default:
msg.payload = "Unrecognised Intent";
return [null, msg];
}

From: Alistair Young [mailto:notifications@github.com] Sent: 18 February 2017 23:55 To: mattotodd/node-red-contrib-alexa node-red-contrib-alexa@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [mattotodd/node-red-contrib-alexa] All intents processed by same flow (#14)

I currently have three intents defined for my skill. Trouble is, whichever intent I invoke, either via voice or using the test page for the skill (by which latter means I know that the correct intent is named in the incoming .json), the same one intent is always invoked in node-red, and the other two are ignored.

Any thoughts?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/mattotodd/node-red-contrib-alexa/issues/14, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFA04120lzEqbxgpEdWbM4IuC4GTHe1Kks5rd4TmgaJpZM4MFTRk.


Scanned by MailDefender Plus, powered by Symantec Email Security.cloud



Scanned by MailDefender Plus, powered by Symantec Email Security.cloud