Dialogflow Integration without Google NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).google;

Log whenever your webhook is called

app.use(bodyParser.json())
...
app.post('/guessnumber', (request, response) => {
dashbot.logIncoming(request.body);
...}

Whenever you send a message, log the request and outgoing message

const msg = {
  speech: "I’m thinking of a number from 0 and 100. What’s your first guess?",
  data: { google: { expect_user_response: true } },
  contextOut: [
    {
      name:"game",
      lifespan:100,
      parameters:{
        answer:72
      }
    }
  ]
}
dashbot.logOutgoing(request.body, msg);
response.send(msg);

Example

Close Menu