Abhilash G
Abhilash G

Reputation: 109

I'm not getting webhook post request for heroku by using actions-on-google library

Hi I'm facing an issue that if i use actions-on-google library i wont get webhook post request for heroku. But when i use dialogflow-fulfillment ill get webhook post request by using

webhookclient({request:req,response:resp})

I have to use heroku no options for me. whether it's works only for firebase?. One more issue i'm unable to get device coarse location when i tested with google mini device but its works fine in simulator.Is their any related to above mentioned issue?

Here is my current code

const {dialogflow,Permission,List} = require('actions-on-google');
const {WebhookClient} = require('dialogflow-fulfillment');
const express = require('express');
const server = express();
server.post('/',function(req,res){
const agent = new WebhookClient({ request: req, response: res });
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
});
server.listen((process.env.PORT || 3000), function () {
    console.log("Server listening");
});

Upvotes: 0

Views: 79

Answers (1)

Nick Felker
Nick Felker

Reputation: 11970

To use an Express server with Actions on Google, follow a snippet similar to:

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

// ... app code here

const expressApp = express().use(bodyParser.json())

expressApp.post('/fulfillment', app)

expressApp.listen(3000)

Upvotes: 1

Related Questions