Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@machinat/dialogflow
Advanced tools
Readme
This module implement the IntentRecognizer
interface with DialogFlow ES API.
npm install @machinat/core @machinat/dialogflow
# or with yarn
yarn add @machinat/core @machinat/dialogflow
Check the Recognizing Intent document and the API references.
You can use this module in two different modes:
In this mode, the DialogFlow project is managed by the package. You maintain the training data along with the codes, and delegate the configuring procedures to the package.
First you need to create a GCP project and a service account to access the API. Follow this guide and set the GOOGLE_APPLICATION_CREDENTIALS
environment variable when running your app.
Then add @machinat/dialogflow
module like this:
import Machinat from '@machinat/core';
import DialogFlow from '@machinat/dialogflow';
const app = Machinat.createApp({
modules: [
DialogFlow.initModule({
projectId: '_YOUR_DIALOGFLOW_PROJECT_ID_',
recognitionData: {
defaultLanguage: 'en',
languages: ['en'],
intents: {
greeting: {
trainingPhrases: {
en: ['hello', 'hi']
}
}
},
},
}),
],
});
Finally you have to call DialogFlowRecognizer.train()
method every time you update the intents data. Like:
// cli/updateDialogFlow.js
import Machinat from '@machinat/core';
import DialogFlow from '@machinat/dialogflow';
const app = Machinat.createApp({/* ... */});
app
.start()
.then(() => {
const [recognizer] = app.useServices([DialogFlow.Recognizer]);
return recognizer.train();
});
It's recommended to run this every time you deploy a new version of your app. It'll not retrain if the intents data remain the same, so it's really cheap to call.
In this mode, you have to manage the DialogFlow project on your own. The package only works as a client for detecting intents.
First you have to prepare a ready-to-use DialogFlow agent. You can follow this guide to create one and add the intents in the DialogFlow console.
Next follow this section to create a service account and set the GOOGLE_APPLICATION_CREDENTIALS
environment variable.
Then add @machinat/dialogflow
module like this:
import Machinat from '@machinat/core';
import DialogFlow from '@machinat/dialogflow';
const app = Machinat.createApp({
modules: [
DialogFlow.initModule({
projectId: '_YOUR_DIALOGFLOW_PROJECT_ID_',
// prevent package to edit the project
manualMode: true,
// detect intent with the default agent in dev
useDefaultAgent: process.env.NODE_ENV !== 'production',
// specify the environment to be used on production
environment: 'production',
recognitionData: {
defaultLanguage: 'en',
languages: ['en'],
intents: {},
},
}),
],
});
If you call DialogFlowRecognizer.train()
method under manual mode, it creates a snapshot version on the environment. You can do it every time you deploy a new version of app, so the DialogFlow agent would have a revertible version along with the version of app.
FAQs
This module implement the [`IntentRecognizer`](https://machinat.com/api/modules/core_base_intentrecognizer.html) interface with [DialogFlow ES](https://cloud.google.com/dialogflow/es/docs) API.
The npm package @machinat/dialogflow receives a total of 12 weekly downloads. As such, @machinat/dialogflow popularity was classified as not popular.
We found that @machinat/dialogflow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.