npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-dialogflow

v3.1.0

Published

Dialog flow module that simplify the web hook handling for your NLP application using NestJS :satellite:

Downloads

45

Readme

Build Status Coverage Status npm version npm Known Vulnerabilities

DialogFlow module for NestJS :satellite:

Dialog flow module that simplify the web hook handling for your NLP application using NestJS

Getting Started

To start using this module you should run the following command

npm i nestjs-dialogflow @nestjs/common @nestjs/core reflect-metadata

Features

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 |

Set up

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 !! :)

Built With

  • NestJS A progressive Node.js framework for building efficient and scalable server-side applications on top of TypeScript & JavaScript (ES6 / ES7 / ES8) heavily inspired by Angular

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Adrien de Peretti

License

This project is licensed under the MIT License - see the LICENSE.md file for details