
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
github.com/adrien2p/nestjs-dialogflow
Advanced tools
Dialog flow module that simplify the web hook handling for your NLP application using NestJS
To start using this module you should run the following command
npm i nestjs-dialogflow @nestjs/common @nestjs/core reflect-metadata
There are 3 decorators provided by the module that allow you to handle intent/action or pick properties from the response.
| Name | behavior |
|---|---|
@DialogFlowIntent('myIntent') public method(param: DialogFlowResponse) | Handle the specified intent into the decorated method |
@DialogFlowAction('myAction') public method(param: DialogFlowResponse) | Handle the specified action into the decorated method |
@DialogFlowIntent('myIntent') public method(@DialogFlowParam('queryResult') param: QueryResult) | Get the value of the property specified through the parameter decorator |
To use the module, you have to import it into your ApplicationModule and call the forRoot in order
to initialize the module. The forRoot method can take as parameters an object with a basePath and a postPath
in order to configure the controller used for the web hook.
@Module({
imports: [
DialogFlowModule.forRoot({
basePath: 'web-hooks',
postPath: 'dialog-flow'
})
]
})
export class ApplicationModule { }
After that, you have to go to your dialogFlow account to set up the url that should be reach to provide the result of
your NLP request into the Fulfillment section of your agent. The url with the default config should looks like https://myurl.me/web-hooks/dialog-flow
To handle an intent, you have to create your own Injectable that will implement all the methods needed in order to handle the concerned intents/action.
@Injectable()
export class MyDialogFlowProvider {
@DialogFlowIntent('My:intent1')
public async handleMyIntent1(dialogFlowResponse: DialogFlowResponse): Promise<DialogFlowFulfillmentResponse> {
/* Your code here */
return {} as DialogFlowFulfillmentResponse;
}
@DialogFlowIntent('My:intent2')
public async handleMyIntent2(dialogFlowResponse: DialogFlowResponse): Promise<DialogFlowFulfillmentResponse> {
/* Your code here */
return {} as DialogFlowFulfillmentResponse;
}
}
You also have the possibility to pick any properties that you need directly from the dialogFlowResponse, to get them from
the handler parameters. To do that, you can use the @DialogFlowParam decorator and pass as parameter a string path to
the property that you want to pick.
@Injectable()
export class MyDialogFlowProvider {
@DialogFlowIntent('My:intent1')
public async handleMyIntent1(@DialogFlowParam('queryResult.outputContexts') outputContexts: OutputContexts): Promise<DialogFlowFulfillmentResponse> {
/* Your code here */
return {} as DialogFlowFulfillmentResponse;
}
@DialogFlowIntent('My:intent2')
public async handleMyIntent2(@DialogFlowParam('queryResult') queryResult: QueryResult): Promise<DialogFlowFulfillmentResponse> {
/* Your code here */
return {} as DialogFlowFulfillmentResponse;
}
}
Inside the DialogFlowModule a middleware is apply in order to validate the token sent by dialogFlow, so when your start
your server, you will have to set the DIALOG_FLOW_AUTHORIZATION_TOKEN env variable.
That's it, you can run your application and test it !! :)
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
Unknown package
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.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.