DEV Community

Cover image for Introduction - A bot responding to a recruiter via Telegram using Watson Assistant's Natural Language Processing
Leandro Boeing Vieira
Leandro Boeing Vieira

Posted on

3 2

Introduction - A bot responding to a recruiter via Telegram using Watson Assistant's Natural Language Processing

I believe that naming articles is as difficult as naming variables and classes, but let's go. For now, that'll do. Although large, it seems significant enough to demonstrate what I intend to cover in this series.

As you may have seen in my LinkedIn post https://www.linkedin.com/posts/leandro-boeing-vieira_tdd-springboot-java-activity-6712687112602349568-FhoD, I will "teach" (how much pretension) how to train a bot to respond to recruiters, making decisions for me, using the good principles of a clean architecture to separate the logic of my business from the necessary infrastructure for that.

Ok, but what are my business rules? Respond to a recruiter based on the context of the conversation. And what is the infra? Telegram API, Watson Assistant, REST etc. You'll see below a drawing of the initial architecture. Of course, it may change until the end of the project, but whenever it happens, I will tell you what has changed.

Bot's Architecture

I was surprised that an architecture for such a cool theme is as simple as that. I finished drawing and thought: something must be missing. But in fact, it has served me well so far. Some points to highlight in relation to the stack I use to implement this architecture:

  1. Telegram itself indicates some unofficial SDKs for developers at https://core.telegram.org/bots/samples.

  2. I decided to use the Java Telegram Bot API (https://github.com/pengrad/java-telegram-bot-api) because it suited me well and I liked the support on github, answering a question in less than 24 hrs.

  3. This implementation of the telegram API provides a much better Webhook mechanism than polling the server for a possible new message. With that, I end up being "nice" with Heroku too, as my application can shut down after 30 minutes of inactivity. With the polling solution, the application receives a POST every X seconds and it never sleeps.

  4. Currently, the application does not yet have the "Take decision based on context" logic developed within the Use Case "Answer Recruiter". I mean, we will develop together. Nice right?! But it already communicates with IBM Watson Assistant and returns the context I need for the bot to be able to answer at least the initial greeting.

  5. I have a minimum logging for development level so I can analyze what the user is sending and what he is receiving as a response. As the application sleeps from time to time (characteristic of Heroku) I always lose these logs. If anyone has a cool idea on how to persist these logs for free, I would appreciate it very much!

It is worth noting that, in an initial idea, I will not "teach" how to create an instance of IBM's Watson Assistant. There is a very complete material at: https://cloud.ibm.com/docs/assistant?topic=assistant-getting-startedodos. But I will show you how I created the dialog nodes, the intents and the entities related to the domain of my application. I think it makes more sense that way.

I'm also not going to teach you how to create a bot on Telegram. It is VERY simple and they teach here: https://core.telegram.org/bots#3- how-do-i-create-a-bot.

That's it for now. We haven't entered "show me the code" yet, but be patient. I thought this introduction is important for us to give a cool rhythm in this series, without too much information at once. I also think it is important that you have a first contact with the architecture, become familiar with it, before looking at the implementation decisions soon.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay