π Getting started
If you are a web developer and know how to host a web application with Express and node.js, ChatAlly will only surprise you with itβs ease of use.
ποΈ Installation
To get started, with the simplest possible chat application, you need to create an npm ESM project, install the core library, a chat server, e.g. the ConsoleServer
and add some middleware.
β Create the application
Create a file index.js
in which you configure your application
Here we create a new chat application, register the ConsoleServer
and implement a very simple middleware, that just echoes the user input.
ChatAlly is fully typed, so you can get full support from your code editor (you might need to setup a tsconfig.json file).
See the guide Writing Middleware for details on how to write your own middleware.
You can now start the application by running
π₯ͺ Add middleware
Of course, this chatbot is quite boring, but you can make it more interesting by adding some middleware, e.g. a module for NLP (Natural Language Processing) like nlp.js.
Install the module
and add it to your configuration instead of the function echo
The function trainNlp
creates a trained NLP module and expects a training corpus at corpus.json
. For this example you can download a corpus.json from nlp.jsβ Github. We integrate nlp.jsβ logging with ChatAllyβs by passing a logger from the application to nlp.js.
The function nlpjsMiddleware
wraps the nlp.js Nlp.process(...)
method in a ChatAlly middleware function.
Now it should be a bit more fun talking to your chatbot.
For details how to train your NLP, see the nlp.js documentation.
π€ What next
The console server limits your audience severely, so maybe you want to try to connect your chatbot with WhatsApp and deploy it to a publicly accessible server.
You could also add more or different middleware, explore the middleware section in the sidebar or start writing your own middleware to add any missing piece.
If you first want to learn more about the core concepts, check out the reference documentation.