Node.js script that responds to google assistant (DiagFlow)
- or -
Post a project like this1980
$15/hr
- Posted:
- Proposals: 5
- Remote
- #2186690
- Completed
Description
Experience Level: Entry
Estimated project duration: 1 - 2 weeks
I have one page of code. It does the following:
Receives a request from Google Assistant (through DiagFlow)
requests information from a web API (of another site)
Send a message back to google assistant with the information contained retrieved from the other website.
The code is complete and works but is written for Diagflow API v1. I need to convert it to DiagFlow API v2. Really all that needs to be changed is the command to understand what the query is from Google Assistant, and feed the information back. For someone familiar with Diagflow this should take no more than 30-60 mins.
Commands being used to notify assistant currently: assistant.tell("This is the information I retrieved, " + msg );
I've pasted the core of the code that needs to be changed below... If you have any questions message me.
const express = require('express');
const ApiAiAssistant = require('actions-on-google').ApiAiAssistant;
app.use(bodyParser.json({type: 'application/json'}));
app.use(express.static('public'));
// Handle webhook requests
app.post('/', function(req, res, next) {
// Log the request headers and body to help in debugging.
// Check the webhook requests coming from Dialogflow by clicking the Logs button the sidebar.
logObject('Request headers: ', req.headers);
logObject('Request body: ', req.body);
// Instantiate a new API.AI assistant object.
const assistant = new ApiAiAssistant({request: req, response: res});
// Declare our action parameters
const PRICE_ACTION = 'price';
const STATUS_ACTION = 'status';
// Create functions to handle intents here
function getPrice(assistant) {
//info in function regarding price
}
// Create functions to handle intents here
function getStatus(assistant) {
//info in function regarding status
}
// Add handler functions to the action router.
let actionRouter = new Map();
actionRouter.set(PRICE_ACTION, getPrice);
actionRouter.set(STATUS_ACTION, getStatus);
// Route requests to the proper handler functions via the action router.
assistant.handleRequest(actionRouter);
});
Receives a request from Google Assistant (through DiagFlow)
requests information from a web API (of another site)
Send a message back to google assistant with the information contained retrieved from the other website.
The code is complete and works but is written for Diagflow API v1. I need to convert it to DiagFlow API v2. Really all that needs to be changed is the command to understand what the query is from Google Assistant, and feed the information back. For someone familiar with Diagflow this should take no more than 30-60 mins.
Commands being used to notify assistant currently: assistant.tell("This is the information I retrieved, " + msg );
I've pasted the core of the code that needs to be changed below... If you have any questions message me.
const express = require('express');
const ApiAiAssistant = require('actions-on-google').ApiAiAssistant;
app.use(bodyParser.json({type: 'application/json'}));
app.use(express.static('public'));
// Handle webhook requests
app.post('/', function(req, res, next) {
// Log the request headers and body to help in debugging.
// Check the webhook requests coming from Dialogflow by clicking the Logs button the sidebar.
logObject('Request headers: ', req.headers);
logObject('Request body: ', req.body);
// Instantiate a new API.AI assistant object.
const assistant = new ApiAiAssistant({request: req, response: res});
// Declare our action parameters
const PRICE_ACTION = 'price';
const STATUS_ACTION = 'status';
// Create functions to handle intents here
function getPrice(assistant) {
//info in function regarding price
}
// Create functions to handle intents here
function getStatus(assistant) {
//info in function regarding status
}
// Add handler functions to the action router.
let actionRouter = new Map();
actionRouter.set(PRICE_ACTION, getPrice);
actionRouter.set(STATUS_ACTION, getStatus);
// Route requests to the proper handler functions via the action router.
assistant.handleRequest(actionRouter);
});
Les S.
97% (6)Projects Completed
9
Freelancers worked with
8
Projects awarded
5%
Last project
28 Oct 2018
Canada
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies