All Projects → adrien2p → Nestjs Dialogflow

adrien2p / Nestjs Dialogflow

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

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Nestjs Dialogflow

Nest Router
Router Module For Nestjs Framework 🚦 🚀
Stars: ✭ 403 (+690.2%)
Mutual labels:  nestjs, addons
Gravekeeper
Informs users that a repo is not maintained anymore.
Stars: ✭ 46 (-9.8%)
Mutual labels:  webhook
Ts Microservice Demo
Demo for microservices / nestjs + kafka + agenda
Stars: ✭ 20 (-60.78%)
Mutual labels:  nestjs
Repository Edge
EDGE - Home Assistant Community Add-ons
Stars: ✭ 42 (-17.65%)
Mutual labels:  addons
Tradercore
Core module for the StockML crypto trading application.
Stars: ✭ 33 (-35.29%)
Mutual labels:  nestjs
Postgraphile Nest
GraphQL (PostGraphile) module for Nest framework (node.js)
Stars: ✭ 43 (-15.69%)
Mutual labels:  nestjs
Authnetjson
Library that abstracts Authorize.Net's JSON APIs. This includes the Advanced Integration Method (AIM), Automated Recurring Billing (ARB), Customer Information Manager (CIM), Transaction Reporting, Simple Integration Method (SIM), and Webhooks.
Stars: ✭ 14 (-72.55%)
Mutual labels:  webhook
Terraform Aws Github Ci
[DEPRECATED] Serverless CI for GitHub using AWS CodeBuild with PR and status support
Stars: ✭ 49 (-3.92%)
Mutual labels:  webhook
Dj Stripe
Django + Stripe Made Easy
Stars: ✭ 1,022 (+1903.92%)
Mutual labels:  webhook
Ng Nest Admin
Angular 和 Nestjs 构建的开源后台管理系统,基于 @ng-nest/ui 组件库
Stars: ✭ 41 (-19.61%)
Mutual labels:  nestjs
Ultimate Backend
Multi tenant SaaS starter kit with cqrs graphql microservice architecture, apollo federation, event source and authentication
Stars: ✭ 978 (+1817.65%)
Mutual labels:  nestjs
Squashed Merge Message
Use Pull Request description as Squashed and Merged commit messages.
Stars: ✭ 34 (-33.33%)
Mutual labels:  addons
Tinder Clone
Fullstack Tinder app clone made with React/Ts/Nest
Stars: ✭ 43 (-15.69%)
Mutual labels:  nestjs
Playwright Addons
Add-ons for Playwright: adblocker, stealth mode
Stars: ✭ 32 (-37.25%)
Mutual labels:  addons
Nx Plugins
A collection of NX plugins baked with love ;)
Stars: ✭ 47 (-7.84%)
Mutual labels:  nestjs
Tutter
Plugin based Github robot
Stars: ✭ 14 (-72.55%)
Mutual labels:  webhook
Nestpress
A production ready personal blogging system on top of NestJS and NEXT.js
Stars: ✭ 38 (-25.49%)
Mutual labels:  nestjs
Webhooker
github webhook handler
Stars: ✭ 42 (-17.65%)
Mutual labels:  webhook
Addon Manager
Manage addons in a Kubernetes cluster
Stars: ✭ 51 (+0%)
Mutual labels:  addons
Authentication Server
A simple authentication service to deliver JWT with Hasura claims, based on users with multiples roles stored in a Postgres database.
Stars: ✭ 48 (-5.88%)
Mutual labels:  webhook

Build Status Coverage Status npm version npm Known Vulnerabilities

DialogFlow module for NestJS 📡

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].