Node-RED vs Cognigy – what is your digital choice?

Authors: Marta Bobyk and Solomiya Kubinska

The new era of Conversational AI and Automation is here – are you with us?

Intro: be further than your market competitors

Despite the abundance of exciting business ideas and various startups, the 21st-century world is still in the deceptive belief that 24 hours are enough. Enough to provide a brilliant service to your clients. Enough to manage your team properly. Enough to gather feedback from the clients, analyze the statistics, carry out improvements, constantly evolve, and … more and more.
But that’s not the reality. To keep pace with the 21st century and be even further than your biting competitors – any business requires smart digitalization and well-timed automation. In fact, a chatbot is one of the most relevant and technologically powerful ways to fulfill the fair desire to be able to solve daily tasks lightly and effectively.
You may ask, why have chatbots become so popular amongst successful business people? Well, there is more than one ground.

 

Why chatbots?

First of all, chatbots are user friendly indeed: available 24/7, easy to use, containing clickable buttons, chat-memory, and requiring one single click to start. As a result, your clients can find the answers to the ever-conceivable question in just a few clicks. Even if it doesn’t exist – why not connect the manager in ONLY this specific case. Saves time, agree?

Secondly, the rapid development of nowadays technologies made it possible to exchange data from different sources in one place. This provides humanity with a great opportunity to gather and read various data, that not only extends clients’ awareness but also brings recognisability and recognition to your service. For instance, the chatbot for your hotel may send a notification with weather conditions a day before the client’s arrival. Or ask if they would like to order a morning coffee, taxi, city excursion, whatever to have the best comfortable trip ever. 

Finally, it should be stressed that chatbots are easy and cheap in implementation – the user only needs to download the particular messenger (if they don’t already use it) and open the bots page. Chatbots are accessible from all devices like smartphones, computers, and tablets. To sum up, the new era of Conversational AI and Automation is here – are you with us?

 

What tools to use?

Nevertheless, great solutions require great tools. So, there are dozed of platforms that assist in:

– proper configuration of the chatbot and its stages

wiring together APIs and online services

management conversations in a flexible graphical interface

– satisfying CI/CD requirements

The list of platforms is huge – basically, they vary in complexity, pricing, and availability of advanced features – for example, a built-in NLP engine or Voice-To-Text//Text-To-Voice converter. However, all of them have a single common feature – any platform is user friendly indeed: as a matter of fact, their UI is easy-readable by people with little or even no technical experience.

So, as a product owner, you are always able to get a high-level visual explanation of chatbot “algorithms” such as clients’ registration process or how chatbot handles FAQ. Essential to highlight that building stable and successful products require a profound comprehension of the full development cycle – that starts with defining product requirements together with BA (business analyst) and continue with developers’ expertise, QA engineer verifying the product grade, and DevOps making chatbot alive. 

Consequently, the platforms are used either for self-education to build mock (pet, home) projects or more seriously and responsibly – to release their own market-leading product with a professional team.

Obviously, an enduring and technically rich experience has brought us chances to sample lots of tools and concepts to find out the best approaches for our clients. In this particular article, we are going to compare two: Cognigy and Node-RED.


Disclaimer: at the end of this article you’ll find the summary comparison table that summarises all the content below.

Cognigy vs Node-red: Pricing and installation

In the first place, we should specify that Node-RED is the open-source free software that all developers can access by downloading it from the official website. To run this software locally the supported version of Node.js is required since Node-RED itself can be installed globally by a single npm command : 

$ sudo npm install -g --unsafe-perm node-red

To start using the platform – write $node-red in the terminal and reach localhost:8080 to see the workspace of your first project.

Moreover, Node-RED can be also instantly accessed by the Web – no Node.js pre-installation required in this case. As one of the ways – use IBM Cloud and it’s Start Kit to kick off. Using IBM Cloud you are able even to deploy your app, but be cautious – IBM has a limit on the number of apps available for the free plan. As a Cloud alternative: all AWS gurus should feel free and confident to build their Node-RED app with AWS Elastic Beanstalk service. To see the full list of installation guides – go here.

By the way, for IoT fans and anyone who gets addicted to the concept of the smart house – check Raspberry PI: computer explanation and Node-RED installation guide. Finally, check stunning Youtube tutorials and step-by-steps: for example, Node-RED with Home Assistant

To sum up, Node-RED is free and has installation guides to any taste, technical credibility, and hardware stuff you own.
Related article: How to create a Telegram Reminder Bot Using Node-RED

 

On the other hand, Cognigy AI is an enterprise conversational automation platform – consequently, it is not free, but positively – offers a free trial to test, compare and decide if the platform meets your needs. Furthermore, you can schedule a demo or join their webinars (e.g. the last one was held due to Cognigy AI v4 release). For today, the vendor has no starting price specified officially –  it is individual for every business, its requirements and any kind of scale to be covered. Additionally, Cognigy is presented as a graphical web editor, so it doesn’t require an installation  (whatever amount of projects you are going to create and deploy). At this point – it limits you with a chance to play around with programming electricity at home, or more important – fast Cloud integration features.

Given the features that Cognigy offers, the leading role amongst conversational tools is rhetorically explained and the paid plan is apparently justified. The most major ones will be definitely described in the next article paragraphs, and you can delve here to get all.

 

Cognigy vs Node-red: Interface

  • Chains layout

Heretofore, interfaces of both solutions looked very similar in the form of chain(s) of nodes beginning at the left side of the editor page, and logically entailing to the right side. Although, with the release of Cognigy V4 the visual structure of the flows was majorly changed. The regular flow editor was merged with the process flow editor. Besides changes in nodes’ functionality that we will talk about later, now a flow goes from top to bottom in Cognigy v4, and still from left to right in the Node-RED case. Given that in Cognigy v3 flows were going from left to right – we can assume that the Cognigy UI/UX team decided to try to implement another type of visual hierarchy to see if organized content follows natural eye movement patterns better.

  • Logging

Node-red is a great platform for developers since it contains a lot of useful UI elements for future bot execution and testing. However, it doesn’t have logs the way we use to think about them. First of all, node-red running logs (as flow starting date & time, running server address and clusters) could be found after typing “node-red” in the command line. Next, as described in the documentation, logs can be stored by two other methods. With the help of logger node-red users are able to output logs through the console or send it to any preferable place. Kibana or AWS Cloudwatch are the most popular services to store logs as they are easy to use and look-up through. Moreover, every company can choose the plan that fits best and meets every business requirement.

On balance, Cognigy logs can be found on the Projects Dashboard page – select the Logs option. Cognigy account users can follow those logs live, they will be automatically appended when new log outputs are being emitted. Also, they can load the history of log entries that happened before, as well as choose the filters to display/hide entries by log type (info/error/debug) within the sidebar. At the same time – the ability to find logs by specific Flow name or User identifier. Each log entry implies timestamp, level, message, and metadata which opens the log function to the full.

However, some disadvantages still exist — no ability to filter logs by Project ID/Project Name, as well as configure Alerts/Events on, to say, error logs from Registration flow – which will be perfect for the Chatbot development process.

  • Chatbot user profile page

What if you would like to overview your chatbot user information and session? Unfortunately, no way to implement this on Node-red UI, if only you don’t add sorting to logs or have the customer Node.js microservice to manage user-related operations.

Cognigy has the Contact management feature, which perfects the UI for Business Analyst, Flow developers, and Project Managers. Moreover, Cognigy allows you to add custom fields endlessly, so it undoubtedly speeds the performance up, when it comes to storing API tokens, their expiration time, and other “active” (“warm”) variables. Another enjoyable point – the ability to review and analyze the session(s). Last, but not least, a feature that we find pleasure in – Handover support. This means that a live Project developer or manager may replace the chatbot, communicate with the service user, and turn the AI chatbot back on to continue.

 

 

  • Access control

What about the access control page? That’s something that node-red doesn’t require you to have. Node-red editor is accessible and it’s really helpful when you are working on a flow with your colleagues or you have to share your working flow with your boss. However, you should be concerned about your privacy as node-red is a flexible platform that satisfies all needs. As you wish there is a possibility to secure your intellectual property by enabling HTTPS access, securing the editor and admin API or securing the HTTP nodes and node-red dashboard. Node-red documentation presents a step-by-step guide on how to fulfill the security checklist.

 

To compare, Cognigy has a throughout Management UI and Access Control page that allows to configure the set of policies to users, as well as sharing options on the projects. Cognigy is able to handle a multi-tenant scenario – these individual tenants are called organizations within Cognigy platform. Each organization has completely separated:

  • projects
  • users
  • API access and keys
  • contact profile schemas
  • quotas & limits

Having created the organization with global rules, quotes, limits, ability to configure system messages, and more importantly – admin, you are able to play around with access within your team. Full list of access rights you can get here.

The cons we notice while developing chatbot flow – access rights are set per user for all projects attached. This disables the flexibility in terms of allowing platflow users to read/update/delete specific chatbots stages – either all or nothing.

  • Debug and info tabs. Versioning. 

The debug and node info tabs can be found on the right side of the workspace. With the first one, you can test the flow and dive into the output object to improve the project flow. Moreover, Node-RED supports multi-pages for flow editing. For instance, different functional parts of the bot can be located on different pages wired together by link nodes. It makes the process of reading a flow easier because nodes don’t overcrowd the flow editor. Node-RED has no history management and flow versioning, unfortunately.

 

Cognigy has a similar interface, nevertheless, there is no additional tab for nodes – all nodes’ information can be found only directly in Cognigy docs. On the right side, a tab with chat, settings, and info is located – this means that you can test flows right in the editor as well, which is again helpful indeed while developing new features. All visual elements are rendered the same way and even buttons are clickable. Moreover, in the Info tab, you can investigate the current input object, your user profile, and context  – in the latter you can check all current flow request responses. 

 

 

Related article: Top Libraries To Quickly and Nicely build Charts with Javascript 

This platform supports multi-flows concept for glueing the project parts – this means that you should:

1) specify the entry flow in the endpoint (connection with the channel: Facebook, web, google assistant, whatever)

2) use Execute/Switch flow blocks to call other flows – which is quite similar to the multi-page concept in Node-red

Another great and unique capability is that Cognigy supports the flow versions – to examine flow history and roll back if required. For example, after the new version of a flow is developed – a platform user can press the LOCK VERSION button, so it will save the current version of flow and create a new draft version. Next changes and new features are implemented in the draft version, and there is always an opportunity to roll back to any to edit, choose the flow previous versions in the Execute flow node, or specify a flow version while exporting the project.

Cognigy vs Node-red: Nodes

Nodes are the principal part of both platforms’ functionality. They define capabilities and comfortability in the process of chatbot creation.

In Node-RED, one can find all nodes together located in the tab on the left part of the editor. Nodes are sorted by categories: 

  • Common (inject, debug, complete, catch, status, link in, link out, comment)
  • Function (function, switch, change, range, template, delay, trigger, exec)
  • Network (mqtt in, mqtt out, http in, http response, http request, websocket in, websocket out, tcp in, tcp out, tcp request, udp in, udp out)
  • Sequence (split, join, sort, batch)
  • Parser (cvs, html, json, xml, yaml)
  • Storage (file, file in, watch, tail)

Nodes can be added to the workspace editor by either:

Node-RED has a very flourishing library, as well as it gives the opportunity to personalize flows. For example, if a user has the same number of nodes repeating, he or she is able to create a subflow and instead of a number of nodes, use only one. This feature makes the process of reading and editing the flow much easier and time-saving. Moreover, to fulfill all the requirements of the product owners, developers can create custom nodes with the necessary functions that will improve the performance of the project. It is noteworthy that Node-RED requires other tools to be able to connect to the chatbots, such as Ngrock or Localtunnel. However, this problem can be solved by using custom nodes for a certain messenger. But it’s unlikely to use custom nodes that are not developed especially for your project, as the authors of the nodes have a right to make changes without notifying about it and they could also stop supporting those nodes. 

To compare, to add a new node in Cognigy one should press the three-dot button on the right side of the node, click on Create Node, and then the drop-down list of the available nodes will appear. Nodes are also grouped according to their functionality, and it won’t be an exaggeration to say they look far more thought out – you are able to tackle almost any tech, marketing, and business needs :

    • Logic (if, once, switch case, interval, stop/pause/execute/switch flow, run process)
    • Basic (say, think, questions (slot, y/n), add/remove from context, set state)
    • Advanced (execute Cognigy NLP, blind mode, reset context, reset state, etc)
    • Marketing (send email, date picker, activate/ deactivate/ update/ delete/ merge user profile)
    • Handover (= live support on, an assistant will connect ASAP from the Cognigy pre-built and very handy page )
    • Api & DB (HTTP Request, SQL, Mongo DB)
    • Custom Modules
    • Code block

In Cognigy editor, not all nodes could be wired together, for example, IF nodes should always be followed with only THEN or ELSE nodes. This approach makes it easier to learn how to construct flows.

However, it feels like Cognigy misses the “continue flow” option – no way to pause and continue the flow at a specific moment. 

In both environments, the labels might be used to customize the node “title” and describe its appointment for the rest of the team.

Cognigy vs Node-red: Integrations

Today one of the most important features that one platform should have is the ability to easily integrate and co-work with other software. As the article goes, we have already mentioned some other tools that work great with both platforms. 

It goes without saying that Node-red’s greatest advantage is that it is compatible with almost everything. Here, we should note that some integrations require strong technical skills, but otherwise, with a help of documentation, all developers will enjoy their experience. Here is a small list of Node-red’s possible cooperation:
  –  messengers: Telegram, Viber, Facebook messenger, what’s up, slack, webpage chatbot integration (by using API’s or custom nodes)

  • cloud platforms and databases: MongoDB, MySQL, Twilio, AWS, Kibana (by using API’s or custom nodes, IBM Watson, Google)
  • local tunnels and servers: ngrok, localtunnel, Jenkins
  • conversational AI (we will look at it closely in the following part)

The same should be said about Cognigy – platform developers created direct integration tools with military precision. For each of the endpoints, there is the ability to configure a data management system, page setup, messenger settings, input/output handlers. The built-in graphical solutions such as Cognigy web and mobile chat widgets allow you to integrate seamlessly with your app, and provide your customers with Conversational AI via Cognigy.  The direct integration with top analytics tools is also included there. Furthermore, Cognigy supports DB connections, which was displayed in the Nodes comparison paragraph. This is exactly the case when a screenshot says more than any other words:

 

Cognigy vs Node-red: NLU and languages support

Nowadays, NLU & NLP are of paramount importance as one of the most amazing technologies. For sure every user will be more satisfied if they feel like the product is personalized, won’t they? That’s where eye-catching tools called NLU & NLP  comes in. The above-mentioned terms stand for Natural Language Understanding and Processing – so, when a user types something with the help of NLU, the chatbot is able to answer it by identifying the user’s intents and wishes. Sounds nice, right? 

Node-red doesn’t contain NLU support itself, however, it opens a lot of opportunities for integrations. For instance, it supports integrations with Dialogflow that is one of the best NLU platforms now, developed by Google. It, also, enables the use of IBM Watson which can help not only in natural language recognition but also in the processing of visual and audio messages. It can be achieved by using APIs or already existing custom nodes. 

Cognigy built-in NLU is claimed to be one of the most powerful nowadays – it allows us to understand what users say with patent-pending innovations and deep-learning algorithms. It truly can participate in the battle with Google Dialogflow or any other NLU “market” leader. As a default, Cognigy will handle all of your intent mapping needs, meaning that you define your intents as described in Intents. The platform also allows to train and perfect NLU right on their UI within the flow.

However, you can also choose to use an external NLU Provider in Cognigy to handle intent mapping, and connect them to Cognigy. These external NLU Connectors will generate the same input object as Cognigy, which enables you to easily switch NLU providers without having to change your flow. Cognigy currently supports connections to Dialogflow, LUIS, Watson, and Alexa Skills which you built with the Alexa skill builder. Finally, Cognigy supports 20+ languages, while machine learning models are language-independent.

Cognigy vs Node-red: CI/CD processes

Node-red’s deployment process depends on the environment one is using to create a flow. IBM Cloud allows you to host your project using their cloud services (the amount of possible hosted data depends on the plan). In case if you are working with it locally you can use any possible cloud service or platform that allows you to host your flow and enables uninterrupted work. Some of them we have already mentioned before in the article, like AWS.

One of the ways to work out the Cognigy project proper environment allocation and support (to make CI/CD alive) is to use their Import/Export feature within 2-3 organization projects. It allows the creation of a super-secure ZIP file with all the projects including flows (version choice available), processes, and all configurations, but avoiding endpoints setup.

Summary

Obviously, Conversational AI platforms are gradually engrossing attention, thus provoking a substantial alteration of chatbots concept perception. As a matter of fact, smart choice and use of conversational AI is an indispensable part of any successful tech project which allows businesses to boost confidence in the market as well as to keep pace with the Tech industry’s rapid development.

Both Node-RED and Cognigy pretend to be a wise choice for your digitization process – which one to choose depends on business needs and product growth perspectives. However, using Conversational AI capabilities and power to the fullest extent, as well as building scalable, flexible, and personalized tech solutions entails a full development cycle with proper CI/CD and delivery processes set.

The article contains a high-level overview of the main features and interface, a summary of which could be found on the comparison table below:

Feature Node-RED Cognigy
Pricing 100% Free
(open-source project)
Free trial exists.

No official starting price published.
Popularity High Medium
Created by IBM (USA, billion corporation, 350k+ employees) Cognigy (Germany, million-funding vendors, up to 100 employees )
First launch date July 6, 2016 – v0.14 Jul 18, 2017 – v2.0
Client Portfolio List Sense Tecnic, Agilite, Go-IoT, Spirit, Opto 22 and many more Daimler, Bosch, Lufthansa, Cisco, Salzburg AG and many more
Partner Network Nothing mentioned so far. Only IoT monitor tool suggests Node-Red connector – more here. Yes, quite huge. You can also find or become a partner.
Documentation quality High, but no versions support High, with versions support
How to’s & Tutorials Yes, rich – componential approach Yes, rich – full project approach
Help center & Support None, only blog and forum or npm support Very good
– always answer emails shortly
– post alerts about environment updates in advance
– during video calls dive into the specific feature and assist in finding tech solutions
Community & forums discussions Forum, active
Slack team channel
Community page – active, but small amount of posts 
Meetups and events Often, worldwide Webinars & Conferences, Trainings
Udemy courses Yes, almost 6k videos  Yes, only 2 for today from Derek Roberti

( VP Technology, North America at Cognigy )

Contribution Yes, many ways Yes, one way
Social media activity Official blog, Facebook, Twitter, GitHub, Wikipedia  Official blog, Facebook, Twitter, Github
Stable releases Yes, Node-RED release notes Yes, Cognigy release notes
As-a-service concept PaaS (Platform as a Service) SaaS (Software as a service)
Installations guides variety Very rich Simple, free trial registration page
Local copy support Yes, docs

Node.js pre-installation required 

Yes, CLI docs

Node.js pre-installation required 
Platform runtime Node.js – lightweight, event-driven, non-blocking Node.js – lightweight, event-driven, non-blocking
NPM support Yes Yes
Hardware support Yes (i.e.  Raspberry PI)  No
Supports IoT solutions Yes – one of the best solutions for IoT projects No
Cloud environment IBM (Bluemix), AWS, MS-Azure, etc Cognigy SaaS cloud or on-premise development
Flow editor in .. Web Web
Flow chains layout Left to right V3: Left to right

V4: Top to bottom

UI Interface convenience level High High

Minor disadvantage: no chance to bulk choose/cut/copy/paste nodes. Only single action available, which is time-consuming.
UI bugs None Very minor
Native logging – live? Yes Yes (+ can be turned off)
Native logging – filter and search tool Low: none built-in exists Medium: includes some, but UI misses the logs flow separation for each Project in organization 
Native logging – log levels Info,debug,error + fatal, warn, trace, off Info,debug,error
Metadata  JSON JSON
Logger customization Easy Hard
Chatbot user profile page No Yes

Major advantage: powerful enough, assists in user management process, is easily customized, speeds up the chatbot performance

Session management page No Yes

Major advantage:
1. saves up resources to develop and store message history
2. allows to read and analyse user sessions

Minor advantage: Cognigy has global TTL set to 30 days: this implies deleting profiles and sessions of users that were inactive for > 30 days.

Handover (live support) No Yes

Major advantage: support and control live conversations without any additional development.

Medium disadvantage: allows to interfere in conversation only by user request. However, this can be evaded.
Management UI No Yes

Medium advantage: to some extend equates to super-admin tool to set organization configuration 
Access control No Yes


Medium advantage: quickly secure your projects.

 

Medium disadvantage: allows to set the access rights to the group of projects, rather then attach rights to each project separately.

Open API No Yes (docs).

Major advantage: allows to send messages to users, imitates user actions, manage user profiles, their sessions without using UI.

Automated testing No Yes

Major advantage: allows to ensure that business objectives are still met after changes have been made

Unlimited scalability Yes (if it is designed as a stateless app) Yes (due to containerized microservices architecture (Kubernetes))
Provides unlimited scaling and built-in resilience to handle peak traffic loads.
Flow versioning Yes, through GitHub built-in interface Yes

 

Major advantages:

1. Flows history management

2. Locked versions take less time to load and therefore perform better under heavy load

 

Medium disadvantage:
1. Limit action steps back supported
2. Up to 6 last flow versions available

Import/Export tools Yes Yes

Medium disadvantage: no bulk actions supported for now.

Databases integration Yes, through libraries.

Both SQL and non-SQL supported.

Yes, built-in

Both SQL and non-SQL supported.

Caching tools No Yes

Major advantage: allows to store request responses in cache and control their expiration time.

Messengers direct integration No

Solution: install custom nodes or use Messenger API directly.
Yes, a wide range
Ready webchat widget No Yes

Major advantage: fast release of beta version for your business

Major disadvantage: non-customized, so that limits business product growth

Ready mobile widget No
NLU direct Connectors No

Solution: install custom nodes or use your API, that accesses NLU modules
Yes

Dialogflow, LUIS, Watson and Alexa Skills
Custom NLU engine No Yes

Major advantage: it is a conversation platform built-in tool, which allows BA and Flow developers to build the best solution fast. Finally, NLU can be trained directly within the Cognigy project.
Built-in intents analytics No Yes
Direct multi-language support No Yes, more than 20+, machine learning models are language-independent
Built-in analytics and business intelligence Yes – dashboard Yes – dashboard
Complex flows “glue” concept Multi-page approach Multi-flow approach
Basic input/output nodes Yes Yes
Voice to text / text to voice Yes – upcoming trend btw Yes – upcoming trend btw
Marketing nodes No Yes

Medium advantage: enables sending emails and user profile management tools through UI

Rich network nodes Yes Yes
Parser nodes Yes

Major advantage: allows to process cvs, html, json, xml, yaml files fast

No
Sequence nodes Yes

Major advantage: allows to manipulate data – split, join, sort, batch

No, manipulate with data only within Code blocks
Storage nodes Yes No
Custom modules support Yes Yes
Rich library with packages Yes

Major advantage: community always publish various Node-RED solutions and utils, which may become nice part of your project

No
Ability to write code Yes, Javascript Yes, Javascript

 

CONTACT US

How to make a Reddit bot with Python

How to make a Reddit bot with Python

How to make a Reddit bot with Python

Automating actions in the browser is a thing that removes routine and helps us spend our time on more useful things. It can be a script to clean up spam mail or a program to calculate your housing costs. There are many ready-made solutions for almost any task automation. In this article, we will revise how to build Reddit bot to automate daily tasks, why we should choose python, how to use Reddit API and what is Python Reddit API Wrapper.

Why Python?

With Python, when you want to create something interesting, you don’t have to sit for several days with books and online guides. Python was one of the first programming languages to cross out the myth about the complexity of programming. It has an extremely simple syntax, easy to write, easy to read, and hard to want more.

Another important aspect is that there are tons of free books, articles, free lessons, lectures dedicated to Python. If you decide to master this language, a lot of the necessary information will always be available to you.

Credits

 

Also, Python has powerful development tools, a huge number of ready-made libraries to solve almost any problem. With so many ready-made solutions and simple Python syntax at hand, you can create interesting projects right from the start.

And the most important, python has a module – PRAW (Python Reddit API Wrapper) – that provides access to Reddit’s API. PRAW already follows all of Reddit’s API rules.

 

How to create a Reddit bot

What you need

 

Python Knowledge:

You need to know at least a little Python to use PRAW – Python Reddit API Wrapper. PRAW supports Python 3.5+.

Reddit Knowledge:

A basic understanding of how Reddit works is a must. In the event you are not already familiar with Reddit, start at Reddit Help.

Reddit Account:

A Reddit account is required to access Reddit’s API. Create one at Reddit.

Client ID & Client Secret:

These two values are needed to access Reddit’s API as a script application (see Authenticating via OAuth for other application types). If you don’t already have a client ID and client secret, follow Reddit’s First Steps Guide to create them.

User-Agent:

A user agent is a unique identifier that helps Reddit determine the source of network requests. To use Reddit’s API, you need a unique and descriptive user agent. The recommended format is <platform>:<app ID>:<version string> (by u/<Reddit username>). For example, android:com.example.myredditapp:v1.2.3 (by u/kemitche). Read more about user agents at Reddit’s API wiki page.

Setting up

And so what do we need for this? Let’s do everything step by step:

  1. Meet the Reddit API documentation
  2. Create application on Reddit
  3. Download the required library (Reddit API) for our interpreter
  4. Test library 

 

Reddit API documentation and access

First of all, take a look at 5 API usage steps, listed on Reddit API Access note. It’s very important, cause if your intended usage is commercial, you’ll need approval from reddit.

Create an application

We go to Reddit and create application:

  • Type name for your application and select “script” option.
  • In ‘redirect uri’ type any random link. 
  • Click the “Create app” button.

Take a look at the  “Personal Use Script” and “Secret”. Note them, we will need this data in next steps.

Write Python code for our Bot

Next we need to download a library for Python by pip manager – Python Reddit API Wrapper

Type “pip install praw”.

Or install the latest version:

Note: The Reddit API has a rate limit of 30 requests per minute, but you can still make quite a bit with this. The PRAW also dynamically handles the rate limiting for you and attempts to be efficient, so you won’t have to worry about crossing the line, but you might wonder regardless why things might not be going as quick as you expect.

To instantiate an instance of PRAW:

import praw

reddit = praw.Reddit(client_id=”CLIENT_ID”, client_secret=”CLIENT_SECRET”,

                     password=”PASSWORD”, user_agent=”USERAGENT”,

                     username=”USERNAME”)

 

With the reddit instance you can then interact with Reddit by different ways:

# Create a submission to r/test

reddit.subreddit(“test”).submit(“Test Submission”, url=”https://reddit.com”)

 

# Comment on a known submission

submission = reddit.submission(url=”https://www.reddit.com/comments/5e1az9″)

submission.reply(“Super rad!”)

 

# Reply to the first comment of a weekly top thread of a moderated community

submission = next(reddit.subreddit(“mod”).top(“week”))

submission.comments[0].reply(“An automated reply”)

 

# Output score for the first 256 items on the frontpage

for submission in reddit.front.hot(limit=256):

    print(submission.score)

 

# Obtain the moderator listing for r/redditdev

for moderator in reddit.subreddit(“redditdev”).moderator():

    print(moderator)

 

On the screenshot added most common features that are really useful for users:

  • Create a submission (Line 7)
  • Comment on a known submission (Line 10). Input needed link and comment that u want. It’s really easy.
  • Reply to the first comment of a weekly top using only two lines of code (Line 14).
  • Output to console score for the first 256 items on the frontpage (Line 18)
  • Get the list of moderators ( Line 22)

Summing up

In this article we showcased how to build Reddit bot in Python, how to use reddit API, what is Python Reddit API Wrapper and how to use it. And this is just a fraction of what you can do with this python library. Everything is limited only by your imagination. Hope you enjoyed this article!

The Chatbots.Studio team develops chatbots in instant messengers – Apple Business Chat, WhatsApp, Telegram, FB Messenger and Viber. If you are interested in articles about using Python in chatbot development, subscribe to our Facebook and stay tuned for new articles. Check out guide How to Create a Telegram Reminder Bot Using Node-RED

Are you interested in chatbot development?

Build your career with Chatbots.Studio! Chatbots.Studio is a place for engineers looking for effective and creative ways to solve complex problems and constantly improving existing approaches to creating new products.

Related article: 30 Ways How to Find a Job In a Chatbot Development Agency!

Do you need to create a bot with complex functionality?

If you need to create a complex solution based on Node-RED, the Chatbots.Studio team will develop a bot of any complexity (our cases). Leave a request in the form below.

How to Create a Telegram Reminder Bot Using Node-RED

You probably wondered if it would be cool to set up reminders in the messenger about the need to drink water or feed your pet. In this article, we will look at how to easily and quickly create a Telegram chatbot in Node-RED, create reminder texts, and test it.

 

What is Node-RED and how does it work?

 

Node-RED is a browser-based data stream editor that allows you to easily combine data streams using various nodes that are collected in a palette (node-red palette).

Node – data node; the nodes of a decentralized network communicate via P2P protocols to exchange information about blocks and transactions. The node is the main building block of the flow.

Nodes are started by either receiving a message from a previous node in the thread or waiting for some external event, such as an incoming HTTP request or timer. They process this message or event and then can send the message to the next nodes in the stream.

The Node-RED palette includes a set of default nodes, which are the basic building blocks for creating threads.

Nodes can be added to the work area by dragging and dropping them from the palette using the quick add dialog or importing from the library or clipboard.

The nodes are connected by lines-wires through their ports. A node can have at most one input port and many output ports. If a node has unused changes, a blue circle appears above it. If there are errors in its configuration, it displays a red triangle.

The essence of the Node-RED editor is that instead of writing programs and commands based on the code, to build the logic for sending messages by the bot, the user just needs to drag and drop objects (nodes) in the visual editor. Since Node-RED provides objects with typical functions, it is easy and affordable for everyone to create projects using them. More complex JavaScript functions can be recreated using a text editor.

The built-in node library allows you to save useful functions, templates or streams for reuse.

Using Node-RED is free, in addition Node-RED can integrate with anything using the API.

 

Node-RED analogs

 

Chatfuel is a useful tool that lets you create chatbots on Facebook. In Chatfuel, you can access external data sources using plugins and create your own chatbots.

 

A chatbot can be configured to recognize specific words or phrases and send predefined responses to users. It can send automated responses to the most common and frequently asked questions. Also, Chatfuel can easily integrate with YouTube, Twitter, JSON, Messenger and others. Chatfuel is free to use, but there is a set of additional advanced paid functionality.

 

Botsify also gives you the ability to create chatbots on a website widget or Facebook messenger without any programming knowledge. Botsify is integrated with many services including WordPress, Shopify, Slack, Alexa, Google Sheets, RSS Feed, JSON API, ZenDesk. An easy-to-use interface allows you to build work logic using visual tools. Botsify is a paid tool and its cost depends on the number of bots you create and the number of bot subscribers.

 

Disadvantages of Node-RED analogues

 

The main disadvantages of Botsify and Chatfuel are these tools are intended either to work with only one messenger, or paid. Therefore, Node-RED is an indispensable tool for getting started and getting acquainted with the creation of bots, as it combines a user-friendly interface, functionality and does not require additional resources.

 

Create a chatbot in Telegram on Node-RED

 

To create a bot in Telegram, you need to go to the application and find @BotFather. Then call the / newbot command and name the bot.

After that, a token is generated, which is required to connect the bot to Node-RED.

 

Installing Node-RED

 

Next, you need to install Node-RED on your computer and start the server with Node-RED on your local machine. In Terminal on your Mac, run the following commands:

 node-red -u “./”

Next, in the browser line, you need to enter http: // localhost: 1880 and we will get access to the pure Node-RED flow, which will be used in further work.

For the setup of webhooks (custom callbacks over HTTPS) and the ability to send messages (logs) to the Node-RED server, you must use the HTTPS protocol, otherwise the messenger will not be able to send the body of the message to a URL that uses a secure connection.

To fix this problem, ngrok (secure tunnels for transferring information to localhost) or localtunnel are most often used. Below we will use the ngrok service. To do this, follow the link to the ngrok website and register. After entering all the required data, you need to download and unzip the file.

Next, open the file through the Terminal on your computer. When registering, each user is provided with an authorization token, and in order to use this service, run the following command in the Terminal command line:

[path to the place where ngrok is located] / ngrok authtoken [token received during registration]

Then start ngrok specifying the port of the local machine as well. In this case, we launch it using the following command:

/ ngrok http 1880

In the future, we set up hooks with the received ngrok secure address, in this case https://41b24bad1175.ngrok.io. Next, we will use the API documentation provided by Telegram.

 

Configuring bot logic

 

To connect and receive messages, you need to apply the following nodes. The inject block will be used to initiate the setup, the bunch of the bot and the Node-RED server is defined in the http request block.

In the http request block, set the following parameters: the POST method, after which we form the URL from the following parts

 

https://api.telegram.org/ [bot id ]/setWebhook?url= [used_ngrok ]/ [webhook_Node_red]

 

  • bot id is provided directly when registering a bot with @BotFather as a parameter in a token separated by a colon. In our case 1170972715: AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI)
  • used_ngrok – in this example https://41b24bad1175.ngrok.io
  • webhook_Node_red is a node that will directly “catch” user messages. We use the http in node, setting it the following parameters method POST, URL – / first_bot, (this url is our Node-RED hook)

Ultimately, our link looks like this:

https://api.telegram.org/bot1170972715:AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI/setWebhook?url=https://41b24bad1175.ngrok.io/first_bot

After filling in all the fields, click Done, and click on the Deploy button in the upper right corner. The Deploy button saves all changes that were made during the flow, so before each test, you must click it, if it is active.

All log messages that come to Node-RED can be found in the tab on the right side of the Debug messages flow. After opening the Debug messages tab, set up the hook by clicking on the node inject.

If all the steps described above are completed correctly, a successful connection response with a 200 status code will be displayed.

 

How to send the first message to a user in a Telegram bot

 

Sending a message to a bot is very simple, for this you need to know who to send what, that is, the text and chat_id parameters.

To find out the chat_id parameter, you can use the debug node and set the complete message object trapping in it. To do this, connect it to a node that catches all our messages and get the following:

Then go to the bot and send it the first message (by default – the / start command)

After that, we get an object that directly displays all the information sent to Telegram. To send a message, you need the id parameter, which can be found in the received log along this path payload.message.chat.id

The following URL is used to send the message:

https://api.telegram.org/bot<bottoken> / sendMessage

All information is transferred in the msg object, which has different levels of nesting and allows you to conveniently transport information. In general, the msg can be imagined as a box with folded data, with which we go to the post office to send as a parcel, parcel post or letter – depending on the complexity of the data object being sent.

 

By analogy, the algorithm below describes how to send an email message in a bot:

1. We indicate what exactly we send, but do not receive or update

   msg.method = “POST”

2. We indicate who will “transport” our letter (different tokens = different “carriers”, “carrier” = “bot”)

msg.url = “https://api.telegram.org/bot1170972715:AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI/sendMessage”

3. And of course, you need to write the message itself and to whom we will send it

msg.payload = {

  “text”: “Drink some water”,

  “chat_id”: msg.payload.message.from.id,

  }

4. Everything is ready, you don’t even need to specify a phone number in the sending template, just tell the node what text to send. To do this, use the command – return msg.

5. Next, you need to “transport” our letter. Since we have already indicated all the information, select – set by msg. method

6. Let’s test it, return to the bot and call the / start command again. The bot should immediately send us a message. It works! HOORAY 🙂

Frequency of sending messages

 

Now we will make the bot remind us every minute that we need to drink water (we take this value of the delay for tests, and later we will increase the time to an hour – we are not sadists).

But first, we need to save the value to whom we are sending the message. Since the object is saved and used only once, the value of this parameter is lost when resending. Therefore, it is necessary to preserve it from the very beginning.

To do this, we use the change node, which allows you to set values in parameters

Now the receiver, that is, the user’s chat_id, will not be lost anywhere and can be reused even if we do not receive a message from the user.

We will also add a timer and set a value of 1 min – a delay 1m block. Let’s connect it to the message sending block. Thus, after the first message is sent, it will take 1 minute and the message will be sent again.

Let’s test it out.

Next, we will increase the frequency of sending messages by 1 hour or any other value – in the delay block.

Bot for reminders in Telegram – ready

 

Without programming skills, anyone can create a bot for reminders to drink water (every minute, hour, or any other period of time).

Let’s complicate the bot a little by adding the ability to independently select reminder hours. To do this, we need to configure the sequence of messages – this will not be difficult, since the first message is displayed after the / start command, and the second command, namely, the start of the timer to receive notifications in all other cases. To do this, we will analyze the text that we receive from the user, we will get 2 options in total.

 

After that, if the user has called the / start command, we will display the message “Hello! Choose how often to remind you about water? 😏 ”, as well as buttons for choosing the frequency – 30 minutes, 1 hour, 2 hours.

Buttons with text in Telegram are announced as follows:

“text”: “Hello! Choose how often to remind you about water? 😏”,

        “reply_markup”: {

            “keyboard”: [[‘Every half hour’], [‘Every hour’], [‘Every two hours’]],

                  ‘resize_keyboard’: true,

      ‘one_time_keyboard’: false

each with [] in the keyboard, reads a new button, and the text in [] is responsible for the inscription that will be displayed on the button. Place buttons and text in msg.payload, add msg.method i msg.url to the function.

 

 msg.method = “POST”

msg.url = “https://api.telegram.org/bot1170972715:AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI/sendMessage”

msg.payload = {

        

        “text”: “Hello! Choose how often to remind you about water? 😏”,

        “reply_markup”: {

            “keyboard”: [[‘Every half hour’], [‘Every hour’], [‘Every two hours’]],

                  ‘resize_keyboard’: true,

      ‘one_time_keyboard’: false

        },

“chat_id”: msg.receiver

}

 

 return msg;

Let’s connect to http request. If this message is not the first, then it must contain one of the text values ​​that we previously displayed on the buttons. All actions that lead from these three conditions are similar, but have different delays in sending messages.

In each of the functions we will display a message, only in “text” – we will display different texts, such as (Great! I will remind you every half hour😌. Great! I will remind you every hour😉, Great! I will remind you every two hours😎)

msg.method = “POST”

msg.url = “https://api.telegram.org/bot1170972715:AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI/sendMessage”

 

msg.payload = {

“text”: “Great! I will remind you every hour😌”,

“chat_id”: msg.receiver}

return msg;

 

 

After displaying the message, add the corresponding delay in sending the next message and the message itself.

msg.method = “POST”

msg.url = “https://api.telegram.org/bot1170972715:AAEntMHSaQEOD2ueLXb1VWmDoidnnbnEQCI/sendMessage”

msg.payload = {

“text”: “Drink some water”,

“chat_id”: msg.receiver}

return msg;

After sending the message, we return to the timer to repeat the sending of the message.

Let’s test

Let’s choose, for example, the first option – Every half hour

Summing up

In this article, we figured out how Node-RED works and how to create a bot in Node-RED Telegram chatbot for reminders.

 

The Chatbots.Studio team develops chat bots in instant messengers – Apple Business Chat, WhatsApp, Telegram, FB Messenger and Viber. If you are interested in articles about using Node-RED in other messengers, subscribe to our Facebook and stay tuned for new articles.

 

Are you interested in creating chatbots?

 

Build your career with Chatbots.Studio! Chatbots.Studio is a place for engineers looking for effective and creative ways to solve complex problems and constantly improving existing approaches to creating new products.

 

Do you need to create a bot with complex functionality?

 

If you need to create a complex solution based on Node-RED, the Chatbots.Studio team will develop a bot of any complexity (our portfolio). To do this, leave a request in the form below.

Our clients’ Viber Chatbot has reached 50.000 subscribers

Great news!

Viber Bot that we built for a Meat Manufacturing Company has reached 50.000 subscribers.

Сhatbot is designed to drive engagement with buyers and job seekers. The main role of this bot is to provide information about promotions, loyalty cards, referral programs and other offers for the two above-mentioned user groups.

Here’s the link to the Viber chatbot (Ukrainian language only).

Here’s the link to the Case Study.

Keep going!

Chatbot

Five Chatbot Use Cases for Apparel Industry

Chatbot

We’ve had quite a few apparel industry leads recently, so by what seems to be a popular demand, we’ve shortlisted top 5 chatbot use cases for this industry. Enjoy 😉

Customer Support 

The overwhelming majority of websites don’t provide a live chat or an FAQ section. That’s unfortunate since a chatbot would be a perfect solution to answer questions customers often ask. Also, from the user’s perspective, it’s much easier to write an inquiry in a chatbot rather than looking for an email to send a question to.

Personalized offers

Our chatbots are connectable to the CRM you use, so that whatever information you collect could be turned into a personalized message. That way, you’ll be able to target a specific need a potential customer has through a special offer or just a reminder to pick up where he/she left off. In any case, a great way to drive sales.

In-messenger communication

There isn’t a better place to tell your customers about a sale or a special deal on apparel,  than in a messenger they use for day-to-day communication. While a good email campaign should benchmark 15-20% as a solid open rate, chatbots allow for up to 80-90% open rate, resulting in much higher sales. 

Also, a messenger is a great tool for updating the shipping/payment status for the goods you sell, since it’s shown to a user in his/her natural habitat so to speak. This is a lot more convenient than looking for an email in an already overcrowded inbox.

Loyalty programs

Loyalty programs are a great way to boost customer retention. Especially if enhanced by the power of engagement chatbots provide. 

Since most modern apparel shops operate in a digital environment, manufacturing physical bonus cards is far from optimal. That’s where a chatbot could come in handy. A customer could easily keep track of the points they collect through a chatbot

Complaint management

With the help of a chatbot, you could automate complaints such as poor shipping quality, wrong item, delayed shipping date, etc. That way, whenever a customer would leave a complaint you could automatically suggest solutions or push it for review without a need for any manual work, resulting in hours and hours of saved time.

Closing notes

We hope you enjoyed reading our article as much as we enjoyed writing it. What would bring us even more joy is boosting your apparel shop with the power of a chatbot. Sounds like a great idea? Drop us a line.

 

top chatbot development agency worldwide

Chatbot.studio is ranked as the second world best chatbot development company

top chatbot development agency worldwide

As the title of this piece of news suggests, we can’t help but be insanely delighted to announce that Mobile App Daily featured Chatbots.Studio as the number two chatbot development agency worldwide, among the other 50 leaders of the industry.

While we’re no strangers to getting awards, we’re especially excited about this one, as it features some of our most world-renowned competitors with whom we are proud to be in the spirit of friendly competition. Also, the two leaders of this top list (Eleks and us) happen to be located in our native Lviv, Ukraine, which makes us even more happy.

This award signifies the hard work and the experience that we’ve mustered over the years, that has shaped our expertise that spans across numerous industries, technologies and business domains.

Having received this surge of motivation, we’re thrilled of what is next to come. Perhaps our next success is going to be working on your project. Drop us a line and let us both find out 😉

Chat bot mock up for the Concord bank

We’ve developed a chat bot for Concord bank

Chat bot mock up for the Concord bank

Wow! What an amazing chatbot we’ve created for Concord bank. 

We bet It will be your favorite Viber bot. Here’s what it can do:

  • Topping up a mobile phone account balance;
  • Prepaid card transactions;
  • Cart-to-card transactions;
  • Getting your CVV in an SMS or another messenger;
  • Blocking/unblocking your card;
  • Quick access to online support.

Just share your phone number to leverage the said features thereby making your life easier 🙂 

We are sure that it is the cutest yet the most convenient chatbot ever.

Chatbots.Studio is #1 AI Developer in Lviv

 

Chatbots.Studio was recognized as the #1 AI Developer in Lviv

 

Chatbots.Studio is the top software development company dedicated to a chatbot, conversation platform development and robotic process automation based in Ukraine. We are building highly valuable platforms and chatbots to automate the businesses and save their owners money. Our main clients (big enterprises and small companies) are getting value every day using our chatbots and systems. Also, we are trusted partners of market leaders Visa and Viber. 

 

 Combining solid marketing expertise in conversational interfaces, with a deep understanding of the latest technologies to deliver tangible business value to our customers. Our services are designed to take your business to the next level while improving engagement and reducing the gap between you and your customers. 

 

 This brings us to the Top AI Developer in Lviv.

 

 For more information about our services visit this page. 

 

 We are looking forward to starting with your project and bringing value to your business!

 

Chatbots.Studio Announced a New Partnership With UiPath!

 

 

In keeping with our new service Robotic Process Automation, we set up a partnership with the market leader and RPA technology vendor – UiPath!
UiPath is the leading platform for enterprise robotic process automation (RPA) built for small businesses, enterprises and IT.

This partnership means access to the industry’s most comprehensive training, technology, and resources.

This mutually beneficial cooperation creates value by helping us to launch digital transformations for businesses and helps clients expand into new markets while reducing overall costs.

 

 

 

How to Build A Powerful, Scalable and Auto-Managed Notification Service Architecture

Almost any 21st-century project requires flexibility and scalability from an architectural point of view. Especially when it comes to chatbot development – if the customer wants to broaden functionality, carry some fresh ideas in, and suggest user new handy features. Push notifications are not a brand new feature, but it’s something that can be developed in an architecturally rational way. In this article, we’ll show you how.

 

 

By the way, in an era of extremely popular technology development, it’s virtually impossible to keep up and choose the most current tools. But is either the developer or the project owner, you should clearly understand that choosing the profound “starter pack” from the very beginning is the key to success.

So, hope this, as one of my best practices, is worth reading at least for comparison reasons (and certainly, this is not a very single solution).

The Problem

Imagine that your retail chatbot sells sports gear, providing lots of customers with a pretty nice service: answering all the typical questions, accepting, processing orders, and in general a lot of manual work has been automated. But you feel like the bot is somewhat raw and missing auto-mailing and the system for long-term processes. Your employees are still writing out the messages about each product delivery manually, and customers have started to subscribe to another service that provides them with something more than just online-purchases: reminders, news, interesting updates, discount notifications, and the wished product availability.

Don’t you miss the push notification service in your project?

Tools to tackle it

No doubt that a student can set a cron-scheduler at the server that will execute an action at a specific time on a recurring basis – very quick, but a primitive solution for such a worthy project. Amongst the main problems:

  • Cron is a system-level process, run on RAM. It’s not even about the limits you may face, but more about the accuracy. Moreover, what about clean up after the server reboot or an unhandled failure?
  • Being not an application process, Cron tangles the development process. Cron may even run at a different time than expected after the server timezone is changed – something that developers shouldn’t worry about, but would.
  • Smallest resolution – 1 minute – you can’t schedule a task that needs to be executed every 30 seconds
  • No queueing – you cannot specify an order for the jobs to complete, to divide them logically and finally make sure that they work independently
  • Dynamic params – imagine you are eager to send some specific text to all users this evening, in 5 hours. If you use the Cron you should create a new CronJob, hardcode the text, build and deploy – sense the difference?

You may investigate more on the weak sides of the Cron scheduler here and there, to be aware of the issue, and keep pace on issue updates.

Bull – is one of the most rational solutions right now, having integrated which allows you to solve the above-highlighted problems and be powerful in scheduling and managing tasks.

Here is a list of the tools that I prefer using for one of the potential architecture solutions. Also, I won’t dive into AWS services launch configuration details, or Redis setup possible problems, but you will definitely understand the general idea and the short hands-on during the article. In this “recipe” you’ll need:

  1. Node.js server
  2. Bull + Redis
  3. AWS EC2 + start scripts
  4. AWS Auto Scaling Group and AWS Elastic Load Balancer

Into the stack

 

1. Node.js server

You may use anything for building your API that will be responsible for managing queues. From  Express.js to hapi – anything you do prefer. The routing system /queue/:name should include:

 

HTTP method
route
description
POST – /job/:type define the delayed job or create & start the repeatable job
GET – /jobs

– /jobs/:id

get the list of all (one) jobs, may pass statistics, count, etc params
PUT – /pause

– /resume

– /empty

manage any queue type in the general conception; empty means removing all jobs from the waiting list
PUT – /retry/job/delayed/:id

– /promote/job/delayed/:id

manage the queue with delayed jobs – promote (force start the job that is in the waiting list) or retry if any has failed
PATCH – /job/repeatable

– /job/delayed/:id

change data or opts fields to modify or reschedule the job
DELETE – /job/repeatable

– /job/delayed/:id

remove either single delayed job by id, or all repeatable jobs from the queue (as all have common time settings)

where :type – the queue type (repeatable/delayed). It’s important to highlight that there are different Bull queues and job methods for the edit and delete processes for different jobs type – so it’s important to diversify them through routes. For instance, to update the delayed job – you should fetch the target job through queue.getJob , and then use job.update(newData), while for repeated one there will be the next action order queue.removeRepeatableByKey -> queue.add.

By the way, a nice solution will be to write the Bull wrapper. QueuesHandler – is the “list” of imported queues handlers from folders /queues/delayed and queues/repeatable. If you’re keen on Typescript – the piece of code below will be even much nicer:

 

 

Bull offers a great list of queue events, so you may be sure that you will miss nothing. Detailed info about:

2. Bull

Bull is a Redis-based queue service for Node.js (if you still are not familiar with the basics of Node.js – we strongly recommend you pass the Node.js tutorial first).

Previously, there was the light alternative – Kue, but now it’s no longer maintained. Anyway, Bull has a list of privileges such as repeatable jobs, atomic ops, and rate limiters. Moreover, there is even the Web GUI working for Bull queues called Bull Arena.

The advantages of the Bull:
  • Low CPU use and high performance. For the cases of huge mailing, the AWS ASG will automatically take care of this.
  • Allows to execute asynchronous functions
  • No limits for queues creation – just divide and conquer. Create as many queues with custom time rules for each and manage them easily.
  • Update, remove, promote, pause and resume – play the queue around however it’s needed
  • Jobs history – you may review all added, executed and even failed jobs with the saved error message. The statistics method allows seeing the queue summary
  • Error handling – there are events, that may catch the error, failure, and the cases when the queue was stalled, drained. Define the convenient handler for these cases and be sure that your developers receive the mail and you get the nice message from your Admin bot telling that planned New Year congratulation for your customers wasn’t finished so that your team will quickly check the stuff.
Disadvantages
  • no service is 100-percent perfect. The project is maintained and always-improved. You may find out more about their current bugs and their statuses on their GitHub page.

What is the queue? This is the imaginary bucket, in which we may gather jobs, each with its own time settings (in 5 minutes, tomorrow at 10 AM, every Sunday), and for all jobs in this bucket, there will be a predefined process handler (function to execute). The handler is called when the time “comes” – either for all jobs in the queue (repeatable) or for a single one from the queue of the delayed ones. We really recommend you separate queues for each repeatable job and for the delayed purposes, even if they have the same executor, but different appointment:

 

 

You may associate the queue with buckets with clothes to-wash that’s of different colors, texture and different powder intended to be used; or as if it’s your daily tasks sorted in work/study/sport/food/ sleep blocks, whatever you like. The main idea is: virtual alarm (Redis) says oh, it’s right X timestamp now (execution time is configured in job opts), you have definitely something scheduled in Y queue, please check – then you just quickly “remember” (bull process on listener) the action (function) and execute it. It doesn’t work every second or millisecond – the alarm knows the exact time points and reacts only if the current time is equal to one of them.

Time settings: this virtually divides the Bull jobs into 2 types: delayed and repeated. Delayed job – this is a scheduled job executed once at this specific time in the future. For instance, “We have just sent your order in the Postal office. Here is your invoice number and please wait for the next notification that will count your buyer score.” The Bull’s add event literally stands for creating a job in the queue with delay field in the opts object and making the job in this queue “wait” for it’s appointed time (will see the difference with scheduled).

 

Value\Queue type
Delayed-jobs queue
Repeatable-jobs queue
Data
different common
Time settings
different common
Handler
common common
Executed
once endlessly (until terminated)

Repeated joba job, that is configured with endless execution every X days/hours/minutes, whatever. To contrast the delayed jobs – bull’s add event, in this case, means creating this event once, and I will work endlessly every XXX milliseconds (under the hood) until the queue is not emptied (by your request or thanks to another scheduler). For example, a sports news daily digest, every 3rd Friday feedback gathering or even every 1st January special 50% discount promotion code for regular customers. You may pass one of the next options in the opts.repeat field when adding the job:

3. Redis

Redis – in-memory, run on RAM key-value storage used for reducing the load of the databases and increasing app performance, the prevailing concurrent of the Memcached and the leader on the caching ring for now.

Here is a great tutorial about manual Redis setup a Linux Machine – you should choose the Amazon Linux 2 AMI for your EC2.

The Redis plays a background role in this service, we just need to prepare it for the Bull, but we do not actually use it directly. In simple words, under the hood Redis helps to save 2 values: time and queue name. Then the Queue.process(job => /*job.data manipulation*/) handler takes everything into his own hands:

4. AWS EC2 machine

It’s not a secret that AWS EC2 is the most popular AWS offering. Go to the EC2 Dashboard, choose the closest region and launch the instance. Configure the instance whatever it’s needed, but pay special attention to the Security Groups’ configuration – they control inbound and outbound traffic. In the Configure Instance tab you’ll see the advanced details chapter – here you should find the User Data input field. Prepare your build & start scripts and paste them right there. 

The #!/bin/bash script should be responsible for:

  1. Installing updates
  2. Installing the software (node.js in our case)
  3. Cloning (downloading) the project
  4. Installing dependencies
  5. Starting the server

Furthermore, consider the safe storage for your .env file – there may be important credentials for accessing your database and the API keys. We highly recommend you to think about AWS KMS encryption beforehand, as well as paying attention to the AWS Secret Manager.

For the CDE reasons (continuous delivery) it will be perfect to configure AWS CodePipeline at your cloud virtual machine, that will automatize build and deploy stages, but this article doesn’t cover this point in detail.

5. AWS Auto Scaling Group

AWS Auto Scaling Group – this service will help us to scale out or scale in automatically, depending on the load. Regarding the fact, that we have supposed that your retail bot has or plans to have a billion customers – this service will definitely make a positive impact on our notifications service.

For instance, if the load increased on any even custom metric rule – the ASG would automatically register the new instances and start the instance based on the script (use the one you created on step 4). There may be average CPU usage defined as the Auto Scaling Rule (for example, CPU should be <= 40%), and the CloudWatch alarm will monitor it. For the custom metric case – reference AWS PutMetricData API and create the CloudWatch metric manually.

You should define the maximum (min = 1) instances running, and  ASG will never exceed this limit. Another great advantage of the ASG is that it will automatically restart the instance if it gets terminated and will replace the unhealthy instances (will highlight the health check in the paragraph below).

In fact, Auto Scaling Groups are free, you will be billed only for the launched instances.

6. AWS Elastic Load Balancer

AWS Elastic Load Balancer – the name speaks for itself: the service will spread the load across multiple downstream instances. Moreover, it will expose a single DNS and redirect the traffic in case of failures – the fantastic power of AWS!

What is important to know: there is a handy possibility to configure the health check for the instances: which route should be called, what response should we expect, how many times we should try to be sure it’s a success and how many times it’s enough to get it as the failure. Add this one for your app to let the AWS manage the unhealthy instances on its own.

Moreover, knowing the Security Group features well – you may easily make the inbound traffic come only from the Load Balancer to your app, so no one will make the use of EC2 IP(s).

Conclusion

I hope the article was interesting for you, and you learned something new. Feel free to write comments, ask questions and liven the discussions up – we’ll be grateful to receive your feedback. And the architecture diagram should serve as a good summary of the article:

Also check out an article How To Build A Scalable Chatbot Architecture From Scratch