0

I am trying to do a simple google home integration with my home server. My only goal is to have it say "Hey google, turn on pool lights" and "Hey Google, turn off pool lights". Both should be mapped to https://mywebsite.com/fullfillment. Once it hits my express server which is running actions-on-google (code below) I have sample code that should properly respond.

Right now whenever I try to create a webhook fulfillment, I just get an error. What am I missing here to just have google home interact with my home server? I've watched countless tutorial and read articles but none really work with remote webhooks, most are fulfillment through firebase or through the inline editor. I have setup OAth as well in the activity linking but I still get the same error "We're sorry but something went wrong. Please try again".

I have also made sure my app and activity controls are enabled as well. I'm just trying to get the action to recognize the webhook and not through this error, if the error at least had some information I could move forward. The "Logs in Google Cloud" also show nothing at all. I have also changed the invocation to a long more custom name and still same error.

Below is a video showing me running through creation of a new Smart Home action on a fresh google account with a postman clip hitting my home server with the correct payload. I've tried this with multiple variations of the webhook url, ngrok was just the latest attempt.

https://youtu.be/Txv1HmP0yW4

Code for my express server below.

const express = require('express');
const bodyParser = require('body-parser');

const {
    dialogflow,
    actionssdk,
    Image,
    Table,
    Carousel,
} = require('actions-on-google');

const app = dialogflow({
    debug: true
});

app.intent('Default Welcome Intent', (conv) => {
    conv.ask('How are you?');
});

app.intent('bye', (conv) => {
    conv.close('See you later!');
});

app.catch((conv, error) => {
    console.error(error);
    conv.ask('I encountered a glitch. Can you say that again?');
});

app.fallback((conv) => {
    conv.ask(`I couldn't understand. Can you say that again?`);
});

const expressApp = express().use(bodyParser.json());
expressApp.post('/fulfillment', app);
expressApp.listen(1349, () => {
    console.log("Test on port 1349");
})
ToniCorinne
  • 503
  • 3
  • 12
97WaterPolo
  • 375
  • 1
  • 3
  • 24
  • 1) The video you provided is private. 2) The code in this question is intended for building a bot using Dialogflow, it won't work for a smart home action. So you either have to create a bot through Dialogflow or change the code to one that works for smart home actions. – Jordi Feb 04 '21 at 12:03
  • @Jordi My bad on the video, forgot to save it as unlisted. Should be available now. How would I change it to work specifically for smart home action? And either way the Google Webhook is never even reaching my server (at least according to ngrok and express) as there is no request ever being made. I just get the error when trying to test it in "Test" center. So even though the response is invalid because it is Dialogflow, shouldn't it still reach my webhook and then fail the test? – 97WaterPolo Feb 04 '21 at 17:14
  • From the video, you seem to be mixing different formats. You should start with the [smart home docs](https://developers.google.com/assistant/smarthome/overview) and check out the [Washer codelab](https://developers.google.com/assistant/smarthome/codelabs) in general. – Nick Felker Feb 04 '21 at 17:23
  • @NickFelker I just followed the entire Washer Codelab tutorial step by step using the completed code. I deployed everything to firebase, got my fulfullment and token URLs and set it up step by step. When I click "Test" and then "Talk to " it still throws the "We're sorry, but something went wrong. Please try again". – 97WaterPolo Feb 05 '21 at 03:57
  • 1
    That's because you're not building a conversational action. You don't . You directly invoke a device – Nick Felker Feb 05 '21 at 16:59
  • @NickFelker I've tried every variation with the washer to try and get it to communicate. I went back to my original code and switched it over to an Actions fulfillment and still. No matter what I do I can NOT get the "Test" to hit my fulfillment endpoint. If I can get it to reach it and fail I can debug from there, but where do I go when the Action never actually reaches my fulfillment server? There is no support, just the "We're sorry, but something went wrong. Please try again" when I try to interact with any of my actions with any input. Is there something wrong in my google account? – 97WaterPolo Feb 07 '21 at 01:34
  • You should look at the server logs and ensure you correctly linked your accounts – Nick Felker Feb 08 '21 at 16:38

1 Answers1

0

If you have created an Actions on Google Project using dialogflow or Assistant conversational action, it won’t work as a Smart Home integration anymore. Please create a new project in the Actions on Google Console, selecting Smart Home as the project type.

Once you create your action, if you intend to build your own server handling smart home requests, a good way to start could be with the Smart Home Washer codelab. You can replace the fulfillment url to your own server, keeping the firebase database and everything else the same. Once you verify you can handle fulfillment requests, you can carry over the rest of the pieces (OAuth) to your server as well. If you get stuck debugging the smart home fulfillments, you can take a look at the Troubleshooting guide.

Anish Yadav
  • 141
  • 4