I am trying to use Actions SDK in my own Server, the actions that I made are showed in Google Assistant, but it's not working, the assistant just closes without showing any errors. This is my code:
'use strict'; const express = require('express'); const bodyParser = require('body-parser'); var exps = express(); exps.use(bodyParser.json()); const {actionssdk} = require('actions-on-google'); const app = actionssdk({debug: true}); const asyncTask = () => new Promise( resolve => setTimeout(resolve, 1000) ); exps.post('/', function(request, response) { app.intent('actions.intent.MAIN', (conv) => { return asyncTask() .then(() => conv.ask('Hi, this is a test!')); }); }); express().use(bodyParser.json(), app).listen(3000);
Request and Debug tabs Both Errors and Response are empty.
Looking at the documentation ( https://developers.google.com/actions/assistant/responses ) suggests that you are attempting to call conv.ask() incorrectly. I would imagine you'd need something like this:
conv.ask(new SimpleResponse({speech: 'Hi, this is a test!', text: 'Hi, this is a test!'}));
I think the issue is that you are creating two different express objects. One gets mounted on the '/' path, but isn't setup to listen on any port. The other listens on a port, but doesn't have any paths setup for it to handle.
Changing your listener line to
exps.use(bodyParser.json(), app).listen(3000);
will make it so the express object where you've setup the '/' path will also be the one listening on the port.
It also appears that your webhook is listening at the '/' path, but you've specified the webhook in your actions.json file as using the '/node/' path. (It is a little difficult to read the screen shot - which is why we request you post the text and not a screen shot.) If you either change your webhook to listen to '/node/' or change the actions.json file to use '/', it should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.