It is tempting to look for modules for every simple task in an application. But what implications can this have?
- [Narrator] Node.js offers a lot modules via the Node package manager NPM. You will find a module for almost everything. And you might feel tempted to use a lot of such third party cultural to your project. But adding a module always means that you trust some other person that they have done it right, didn't introduce security problems, and will maintain this module in the future as well. Just recently, a huge number of applications were effected when a module called left-pad had a problem. Let's look into the source code of left-pad.
We see that left-pad is just a few lines of code, and just really trivial. Why would you want to take the risk of an external dependency for just a few lines of code? While working on a project, you should always ask yourself if you really need a module, or if you should better write the piece of code yourself. If you have to use a module, be sure that the author has some credibility, and that they're a frequent leases, and no old non-answered issues on GitHub. In our project we want to use the slack API to create a BOT, and naturally there are a lot of modules that provide this.
I agree that we don't want to implement all these API methods in to real-time messaging over web sockets on our own. Take some time to search and explore modules related to Slackin on NPM. Look through the issues on GitHub, check how frequently there are new releases. I did some research as well, and found that there is a module called node.slack-stk, it's provided by the Slack team. This is a trustworthy source, and we can expect that the module will always be on par with Slack's API.
So in our project, we will use this module. It may be a bit more low level than other modules breeding on it, but this also means that it offers us the freedom to implement our functionality exactly as we want to. Please take some time to read through the documentation of node.slack-sdk to see what it provides.
After explaining some basics about Node.js and microservices, Daniel shows you how to sketch out the planned architecture for your application and get the boilerplate code, modules, and credentials in place. Next, he shows how to create a bot user in Slack, connect to Slack, and post messages. He also shows you how to get your bot to process variations in text by creating logic that delegates the processing of intent to dedicated modules. Lastly, he shows how to register additional services and he covers how to use monitoring to identify architectural or performance issues.
- Using Slack APIs
- Sketching out a Slack bot architecture
- Setting up a project and choosing modules
- Creating and naming your bot
- Connecting to Slack
- Setting up and using natural language processing
- Routing by intents
- Implementing geocoding and time calculation
- Adding and monitoring services