How to build a Dialogflow chatbot for website? [closed] - dialogflow-es

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I want to run my first, simple chatbot on my website. So I chose that stack:
Dialogflow (ML, AI etc.)
Dialogflow Messeger (frontend communicator app)
Firebase Functions with Dialogflow Fulfillment Library (backend)
I noticed that Dialogflow Fulfillment Library is no longer maintained. And for example quick replies (rich message) works on Dialogflow Console, but doesn’t work on Dialogflow Messenger.
My code (fulfillment webhook):
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');
const { Suggestion } = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
let intentMap = new Map();
intentMap.set('richmessage', richMessageButtonHandler);
function richMessageButtonHandler(agent) {
agent.add('Select one');
agent.add(new Suggestion('Quick Reply'));
agent.add(new Suggestion('Suggestion'));
}
agent.handleRequest(intentMap);
});
Question: I need simple chatbot for website with quick replies (suggestions). Can I achieve that with these technologies (without Facebook Messenger or other external service)? Is any successor? Some alternatives?
Thanks in advance!

DialogFlow is a good platform (free, NL capabilities, multi-channels) but it is not ideal for web sites, or at least it does not have a specific browser widget.
The DialogFlow web demo is meant for development/testing and cannot be easily customised. There are some options out there (Kommunicate, BotCopy) to add a webchat plugin for a web site or alternatively using the SDK you can build the web chat frontend you want (similar as dialogflow-web-v2 on GitHub)

If you want to make your BOT part of an Omnichannel platform you can go with Kommunicate. That is the one I'm using it at the moment. BotCopy just integrate your chat into a web page but without the omnichannel capability or, the hardcore one, develop your own with node.js or angular.js etc. You can try also Twilio Flex but it requires other intermidiate components.

Try Rasa also (https://rasa.com/)
positives
free
opensourse
privacy
negative
need a system resource to run and train bot

Related

Is it possible to invoke Google Dialogflow webhook from external api by enabling Beta Features and API

I have been working on a POC and I am able to invoke Dialogflow fulfilment webhook from external API and get the response but not able to get the knowledge base response when Beta feature options are disabled. When I enable Beta features, I am getting knowledge base response but not getting webhook response. Not able to make both Knowledgebase and webhook work together with beta features option.
Is it possible with Dialogflow CX ?
Knowledge works but not Webhook with following:
const knflow = require('#google-cloud/dialogflow').v2beta1;
const ksclient = new knflow.SessionsClient({
keyFilename: "C:/Temp/XXXXXX.json"
});
const sessionPath = ksclient.projectAgentSessionPath(
projectId,
sessionId
);
var responses = await ksclient.detectIntent(request);
Webhook works but not knowledgebase with the following:
const sessionPath = sessionClient.sessionPath(projectid,sessionid);
var chatMessage = chatRequest.messageDetails.message;
var responses = await sessionClient.detectIntent(request);
In Dialogflow ES, Knowledge Connector is in Beta version. You will only be able to use Knowledge Connectors on your agent if you've enabled the 'Beta features and APIs' option in your agent settings.
If you use nodeJS client library, consider to check the DetectIntent Response, response from Webhook can be found on fulfillmentText or fulfillmentMessages fields under queryResult. While responses from Knowledge Connectors can be found under alternativeQueryResults.
You may also consider to upgrade ‘#google-cloud/dialogflow’ library version to "^3.3.0" in your package.json.
For agent to Human hand-off, you can take a look at this sample github implementation: https://github.com/dialogflow/agent-human-handoff-nodejs.

How to use Firebase Database in Google Actions?

I'm new to programming Actions for Google Home/Assistant.
I have been using the Inline-Editor under Fulfilment lately and it works fine. Now I want to start using the Firebase DB.
As it says const functions = require('firebase-functions'); in the first lines of the Inline Editor I am assuming, that the Database is ready to use?
If so, how do I access it?
Although Dialogflow uses Firebase Functions to let you do inline code-editing, it doesn't sound like it is a full-fledged Firebase environment. There may be APIs on the back-end that are not setup.
The Dialogflow In-line Fulfillment is meant for simple logic testing and simple operations.
Fortunately - it isn't difficult to take that code and expand it into code that you write... and still host on Firebase Functions! See https://firebase.google.com/docs/functions/get-started for the tools you'll need to install to get started.
For a more extensive tutorial about writing Firebase Functions that work with Dialogflow and getting started with Firebase Functions, you can take a look at the codelab from Google at https://codelabs.developers.google.com/codelabs/assistant-dialogflow-nodejs/index.html
You can use the Google Realtime Database package firebase-admin
const admin = require("firebase-admin");
admin.initializeApp(functions.config().firebase);
const db = admin.database();
const ref = db.ref("/");
And to set a value in the database
ref.set({yourKey: 'value'});

Is node.js Express 4.x suitable for making web api's now vs alternative node packages [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I know there are alternatives such as restify but would like to stick with the more familiar express. Does anyone have examples (and or experience/tips to share) of successful implementations of a web api with Express 4.x, such that I could forgo having to go down an alternative route?
restify uses very similar patterns to express for routing, etc., so if you plan on doing any fancy API stuff you might as well just npm install restify and use it in place of express. Here's a minimal example of a restify application from its homepage:
var restify = require('restify');
function respond(req, res, next) {
res.send('hello ' + req.params.name);
next();
}
var server = restify.createServer();
server.get('/hello/:name', respond);
server.head('/hello/:name', respond);
server.listen(8080, function() {
console.log('%s listening at %s', server.name, server.url);
});
On the flipside, it's not like express has any specific disadvantages in terms of usage for APIs (and performance may actually be better, looking around at other StackOverflow questions). If you don't need any of the features that restify provides and express doesn't, and you have no plans for using them in the future, then you may as well just stick with express. It's all a matter of your needs for your API, really; there are plenty of other questions on StackOverflow regarding restify vs. express for specific cases, so take a look around at what information is already available.

What is Express.js? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 10 months ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Needs more focus Update the question so it focuses on one problem only by editing this post.
Improve this question
I am a learner in Node.js.
What's Express.js?
What's the purpose of it with Node.js?
Why do we actually need Express.js? How is it useful for us to use with Node.js?
What's Redis? Does it come with Express.js?
1) What is Express.js?
Express.js is a Node.js framework. It's the most popular framework as of now (the most starred on NPM).
.
It's built around configuration and granular simplicity of Connect middleware. Some people compare Express.js to Ruby Sinatra vs. the bulky and opinionated Ruby on Rails.
2) What is the purpose of it with Node.js?
That you don't have to repeat same code over and over again. Node.js is a low-level I/O mechanism which has an HTTP module. If you just use an HTTP module, a lot of work like parsing the payload, cookies, storing sessions (in memory or in Redis), selecting the right route pattern based on regular expressions will have to be re-implemented. With Express.js, it is just there for you to use.
3) Why do we actually need Express.js? How it is useful for us to use with Node.js?
The first answer should answer your question. If no, then try to write a small REST API server in plain Node.js (that is, using only core modules) and then in Express.js. The latter will take you 5-10x less time and lines of code.
What is Redis? Does it come with Express.js?
Redis is a fast persistent key-value storage. You can optionally use it for storing sessions with Express.js, but you don't need to. By default, Express.js has memory storage for sessions. Redis also can be use for queueing jobs, for example, email jobs.
Check out my tutorial on REST API server with Express.js.
MVC but not by itself
Express.js is not an model-view-controller framework by itself. You need to bring your own object-relational mapping libraries such as Mongoose for MongoDB, Sequelize (http://sequelizejs.com) for SQL databases, Waterline (https://github.com/balderdashy/waterline) for many databases into the stack.
Alternatives
Other Node.js frameworks to consider (https://www.quora.com/Node-js/Which-Node-js-framework-is-best-for-building-a-RESTful-API):
UPDATE: I put together this resource that aid people in choosing Node.js frameworks: http://nodeframework.com
UPDATE2: We added some GitHub stats to nodeframework.com so now you can compare the level of social proof (GitHub stars) for 30+ frameworks on one page.
Full-stack:
http://sailsjs.org
http://derbyjs.com/
Just REST API:
http://mcavage.github.io/node-restify/
Ruby on Rails like:
http://railwayjs.com/
http://geddyjs.org/
Sinatra like:
http://expressjs.com/
Other:
http://flatironjs.org/
https://github.com/isaacs/npm-www
http://frisbyjs.com/
Middleware:
http://www.senchalabs.org/connect/
Static site generators:
http://docpad.org
https://github.com/jnordberg/wintersmith
http://blacksmith.jit.su/
https://github.com/felixge/node-romulus
https://github.com/caolan/petrify
This is over simplifying it, but Express.js is to Node.js what Ruby on Rails or Sinatra is to Ruby.
Express 3.x is a light-weight web application framework to help organize your web application into an MVC architecture on the server side. You can use a variety of choices for your templating language (like EJS, Jade, and Dust.js).
You can then use a database like MongoDB with Mongoose (for modeling) to provide a backend for your Node.js application. Express.js basically helps you manage everything, from routes, to handling requests and views.
Redis is a key/value store -- commonly used for sessions and caching in Node.js applications. You can do a lot more with it, but that's what I'm using it for. I use MongoDB for more complex relationships, like line-item <-> order <-> user relationships. There are modules (most notably connect-redis) that will work with Express.js. You will need to install the Redis database on your server.
Here is a link to the Express 3.x guide: https://expressjs.com/en/3x/api.html
What is Express.js?
Express.js is a Node.js web application server framework, designed for
building single-page, multi-page, and hybrid web applications. It is
the de facto standard server framework for node.js.
Frameworks built on Express.
Several popular Node.js frameworks are built on Express:
LoopBack: Highly-extensible, open-source Node.js framework for quickly
creating dynamic end-to-end REST APIs.
Sails: MVC framework for
Node.js for building practical, production-ready apps.
Kraken: Secure and scalable layer that extends Express by providing structure and
convention.
MEAN: Opinionated fullstack JavaScript framework that
simplifies and accelerates web application development.
What is the purpose of it with Node.js?
Why do we actually need Express.js? How it is useful for us to use with Node.js?
Express adds dead simple routing and support for Connect middleware, allowing many extensions and useful features.
For example,
Want sessions? It's there
Want POST body / query string parsing? It's
there
Want easy templating through jade, mustache, ejs, etc? It's
there
Want graceful error handling that won't cause the entire server
to crash?
Express.js is a modular web framework for Node.js
It is used for easier creation of web applications and services
Express.js simplifies development and makes it easier to write secure, modular and fast applications. You can do all that in plain old Node.js, but some bugs can (and will) surface, including security concerns (eg. not escaping a string properly)
Redis is an in-memory database system known for its fast
performance. No, but you can use it with Express.js using a redis
client
I couldn't be more concise than this. For all your other needs and information, Google is your friend.
ExpressJS is bare-bones web application framework on top of NodeJS.
It can be used to build WebApps, RESTFUL APIs etc quickly.
Supports multiple template engines like Jade, EJS.
ExpressJS keeps only a minimalist functionality as core features and as such there are no ORMs or DBs supported as default. But with a little effort expressjs apps can be integrated with different databases.
For a getting started guide on creating ExpressJS apps, look into the following link:
ExpressJS Introductory Tutorial
Express is a module framework for Node that you can use for applications that are based on server/s that will "listen" for any input/connection requests from clients. When you use it in Node, it is just saying that you are requesting the use of the built-in Express file from your Node modules.
Express is the "backbone" of a lot of Web Apps that have their back end in NodeJS. From what I know, its primary asset being the providence of a routing system that handles the services of "interaction" between 2 hosts. There are plenty of alternatives for it, such as Sails.
Express.js is a framework used for Node and it is most commonly used as a web application for node js.
Here is a link to a video on how to quickly set up a node app with express https://www.youtube.com/watch?v=QEcuSSnqvck
Express.js created by TJ Holowaychuk and now managed by the community. It is one of the most popular frameworks in the node.js. Express can also be used to develop various products such as web applications or RESTful API.For more information please read on the expressjs.com official site.
ExpressJS is a web application framework that provides you with a simple API to build websites, web apps and back ends. With ExpressJS, you need not worry about low level protocols, processes, etc.
Fast, unopinionated, minimalist web framework for Node.js
Pug (earlier known as Jade) is a terse language for writing HTML templates. It −
Produces HTML
Supports dynamic code
Supports reusability (DRY)
It is one of the most popular template language used with Express.
A perfect example of its power
router.route('/recordScore').post(async(req, res) => {
let gold_nation = req.body.gold && req.body.gold.nationality;
let silver_nation = req.body.silver && req.body.silver.nationality;
let bronze_nation = req.body.bronze && req.body.bronze.nationality;
let competition_id = req.body.competition_id;
console.log(gold_nation)
console.log(silver_nation)
req.body.gold && await country.updateOne({"flag" : gold_nation}, { $inc: { gold: 1 } });
req.body.silver && await country.updateOne({"flag" : silver_nation}, { $inc: { silver: 1 } });
req.body.bronze && await country.updateOne({"flag" : bronze_nation}, { $inc: { bronze: 1 } });
console.log(competition_id)
//await competition.updateOne({"_id" : competition_id}, {$set: {recorded : true}});
//!! Uncomment this and change model/competition.ts set recorer to recorded
// this is commented out so you can test adding medals for every case and not creating competitions every time
res.status(200).json("Success");
});
async record(){
let index = this.competitions.findIndex(e => e._id == this.selectedCompetition);
let goldIndex = this.competitors.findIndex(e => e._id == this.goldWinner);
let silverIndex = this.competitors.findIndex(e => e._id == this.silverWinner);
let bronzeIndex = this.competitors.findIndex(e => e._id == this.bronzeWinner);
console.log(this.competitors[goldIndex]);
console.log(this.competitors[1-goldIndex]);
this.sportService.recordCompetition(this.competitors[goldIndex],
this.competitors[1-goldIndex],
null,
this.competitions[index]).subscribe((m:string) => this.reset(m))
}
reset(message: string){
this.statusMessage = message;
if(message == "Success"){
this.competitions = this.competitions.filter( (c) => c._id != this.selectedCompetition);
this.goldWinner = '';
this.silverWinner = '';
this.bronzeWinner = '';
}
setTimeout(()=>{
this.statusMessage = '';
}, 3000);
}
router.route('/registerCompetitor').post(async(req, res) => {
//! PROVJERI DA LI JE FORMIRANJE TAKMICENJA ZAVRSENO
let competitors = req.body.map( c => ({
name: c.name,
gender: c.gender,
nationality: c.nationality,
sport: c.sport,
disciplines: c.disciplines
}));
console.log(competitors)
await country.updateOne({"flag" : competitors[0].nationality}, { $inc: { numberOfCompetitors: competitors.length } });
await competitor.collection
.insertMany(competitors)
.then( u => {
res.status(200).json("Ok")
})
.catch(err =>{ res.status(400).json("notOk");
});
});

Node.js integration with MS Exchange EWS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am attempting to use Node.js to call the SOAP Exchange EWS services. I have created a simple http client like so:
var https = require('https');
var username = 'user';
var password = 'password';
var auth = 'NTLM ' + new Buffer(username + ":" + password).toString('base64');
var options = {
host : 'exchangehost',
port : 443,
method : 'post',
path : '/Exchange.asmx',
headers : { Authorization : auth }
};
var request = https.request(options, function(response) {
console.log('Status: ' + response.statusCode);
};
request.write('<soapenv:Envelope ...></soapenv:Envelope>');
request.end();
I receive a status code 401, I suspect because I am not doing the three steps involved for NTLM authentication (http://www.innovation.ch/personal/ronald/ntlm.html). Does anyone know of a Node.js module for communicating with Exchange EWS directly or for authenticating using NTLM, or am I going to need to implement that protocol for Node.js myself? Any assistance is greatly appreciated.
I have used node-ews successfully to communicate with EWS.
node-ews uses httpntlm internally for NTLM authentication.
Personally, I think node-ews is your best bet, since its pretty much already implemented everything you need to interact with EWS.
Have you tried the httpntlm module? https://github.com/SamDecrock/node-http-ntlm
Have you tried ews-javascript-api npm module, it has all the features you are looking at + very simple ntlm authentication using ews-javascript-api-auth module. NTLMv2 is also supported.
I added this as answer as it would provide complete answer to question title (integration). These are github links, question is little generic so samples provided at github readme should work.
[disclaimer - I am the author]
I've found this one Node.js module that supports communicating with Exchange 2010, however I'm still trying to figure out how to use it personally, the documentation is light.
https://npmjs.org/package/exchanger

Resources