Amazon Alexa Skill to talk to your Kegbot

Yeah this means that the lambda is having trouble connecting to your Kegbot and it’s timing out waiting for a response.

There could be a lot of reasons for this and debugging Lambda is tricky. I would suggest you put some debug statements into the index.js file to troubleshoot. For example, I’ve added this to mine to validate the URL is getting picked up from the default.js config file:

const handlers = {
'OnTap': function () {
    var that = this;
    req.url = config.KB_server + '/api/taps/';

    console.log('Attempting to connect to URL: ' + req.url); //ADD THIS DEBUG LINE HERE
    
    request(req, function (err, response, body) {....................

You will have to re-zip and re-upload to Lambda for this to take effect, but when you test you’ll at least see that Lambda is trying to connect to the correct URL.

Appreciate your help on this!

URL is fine in the request…i am a total idiot…

i could have SWORN i tested from outside…

NAT rule is there but not working so looks to be firewall issue, stand by

Looks like it changed with my ISP recently, so it was open but now they block it. I tried to change to a redirect at the router but kegbot doesn’t seem to like that and the API does not come back.

I’ll get 80 unblocked or change listening port of kegbot and report back. Thanks again Johnny I think we have cracked it!

edit: I just removed and readded the NAT rule to forward a different port and made a successful API call aaaanddd

{
“version”: “1.0”,
“response”: {
“shouldEndSession”: true,
“outputSpeech”: {
“type”: “SSML”,
“ssml”: " Keg Bot has Nitro Milk Stout on tap "
}
},
“sessionAttributes”: {},
“userAgent”: “ask-nodejs/1.0.25 Node/v8.10.0”
}

THANKYOU!

Sorry to miss something so obvious and waste your time, thanks again it would have taken me 5 times longer to pick up that config file structure too.

Cheers!

sorry not done yet :slight_smile: it is only reporting on the first tap, can it handle more than one tap?

Awesome! Stinks that your ISP blocks 80 by default, but I get it.

Fortunately mine has 80 and 443 open, but I do not have it pointed directly to the Kegbot Server. I’m actually using a separate Raspberry Pi as a reverse proxy that forwards requests to my kegbot (as well as other servers in my network). I’ve also set it up so that all requests are via HTTPS which is why for now I’m OK leaving my privacy setting to Public. I should probably do a write-up about that as well.

As for multiple taps, I currently only have one beer on tap so I had not tested that, but looking at the javascript code it looks like it just returns the data for the first tap it sees. I’m out of pocket for the weekend, but next week I’ll see if I can update the code to loop through all “active” taps and return the values for each one. (i.e. “Keg bot has Nitro Milk Stout, Bud Light, and Fosters on tap” or “Keg bot has 25 percent of Nitro Milk Stout, 0 percent of Bud Light, and 50 percent of Fosters remaining”). The Cleveland Browns won last night so hit the Bud Light hard :joy:

1 Like

It would be great of you could say what is on tap two and have it hit that relevant API filter but whatever you came up with would be awesome.

I wish I could dev, may need to start studying again…

You have saved my bacon on two issues now Johnny, I owe you a beer!

edit: I see what you are saying, it returns the first object in the array from the JSON response.

Wonder if we could set up an intent for each tap for “ontap” and “volume” and then in the utterances just have the tap number specified. Then put those in as separate functions in index.js?

that works

image

Sweet!! Yeah that works well!

I also see that Alexa supports intent slots (i.e. “what beer is on tap {tap_number}”) that will pass in that argument to the function. That way you wouldn’t need a separate function for each tap, it would be dynamic. I’ll have to play with that next week!

1 Like

aw yeah I see, I’ll see if I can work out how to assign that within the function. Much tidier

edit: I didn’t make too much progress, I see what needs to happen. I setup the slot types and can see the skill sending the right slot type in JSON to Lambda but I’m not sure how to call that within the function.

intent.slot… etc is a little confusing

I tried assigning it to a variable and then just logging that output but it was failing. maybe I need to declare the variable somewhere first… not sure. I will wait for you to have a crack Johnny, definitely looks achievable with minimal effort

Any luck ?

I just set it up with 6 functions for my taps, works perfectly.

I do need to set another call to loop through all taps.

Hey, yeah I was able to get the “slot” thing to work. Here’s the flow for my 2-tap system:

  • “Alexa - what is on tap?”: “You have Bud Light and Dos Equis on tap”
  • “Alexa - what is on tap 1?”: “You have Bud Light on tap 1”
  • “Alexa - what is on tap 3?”: “There is no tap with that number”

The flow works similar with the “How much beer is left?” questions.

I’ll look back at the code and edit this post, got distracted with other projects and tasks!! One issue I’m facing is that in “Test” mode it seems like things time-out or something. It will work perfectly for a day or two and then stop. I’ll then have to disable/re-enable my alexa skill. I’ll update again with the code later today or tomorrow.

1 Like

Hey Johnny, I just set my kegbot back up. Would love to get your config for the slots if possible.

Are there any changes required to the lambda function or is it all skill side?

Hey @moad

I actually haven’t messed with the Kegbot Alexa skill in a long time, but I’m working on another skill for a separate project that’s helping me get a little more practice with developing for Alexa. Give me a few days to wrap that project up and I’ll dive back into the Kegbot implementation!

1 Like

Hi @johnnyruz, I’m about to try to tackle this myself and thought I’d ask if you could post the updated config you settled on please? Thanks!

Just as an FYI to anyone setting this up in the future, @e2r4 just updated his alexa-lamda project mentioned in the original post with a ton of new functionality. I got it set up quickly yesterday and it’s an awesome new addition to the kegbot project. Cheers for the work Pat, awesome stuff!

2 Likes

I just rebuilt mine with the updates, thanks so much for the work @e2r4 this is awesome!

2 Likes