Customize Starter Kit
In this guide, we’ll walk you through using and customizing the starter kit code to build your own Chatbot. You’ll learn about the structure of the starter kit, enabling you to make updates and manage user interactions effectively.
Tip
First read about starter kit structure here
Scenario:
Let’s start with a simple example. Suppose that when a user sends “hi”, you want to display a greeting message along with two buttons for selecting their preferred language. When the user selects a language button, the language should change accordingly.
Present two buttons for language selection along with welcome message when user sends “hi”
Show a message for language change confirmation.
Implementation
Update Message Processing
Next, we’ll update the processMessage function to handle user interactions. When the user sends “hi”, we’ll call both the sendWelcomeMessage and createButtons functions.
if (intent === 'greeting') { this.message.sendWelcomeMessage(from, userData.language); }
Replace this code block with below code
if (body.text.body === 'greeting') { this.message.sendWelcomeMessage(from, userData.language); await this.createButtons(from); }
NLP
In the above guide, we saw how to customize the starter kit to create our own bot and handle user interaction. Let’s assume you have to design a chatbot that that takes the user input or query and provides the answers for their query. This is where the NLP becomes important.
NLP, or Natural Language Processing, is a branch of artificial intelligence (AI) focused on enabling computers to understand, interpret, and generate human language in a way that is both meaningful and useful. It involves the interaction between computers and humans through natural language.
NLP encompasses a range of tasks and techniques, including:
Text Processing: Breaking down text into its constituent parts, such as words, sentences, and paragraphs.
Tokenization: Splitting text into smaller units, or tokens, such as words or phrases.
Part-of-Speech Tagging: Assigning grammatical categories (e.g., noun, verb, adjective) to words in a sentence.
Named Entity Recognition (NER): Identifying and categorizing named entities (e.g., names of people, organizations, locations) in text.
Sentiment Analysis: Determining the sentiment or opinion expressed in a piece of text, such as positive, negative, or neutral.
Machine Translation: Translating text from one language to another automatically.
Question Answering: Generating answers to questions posed in natural language.
Overall, NLP enables computers to process, analyze, and understand human language, which has applications in various fields, including virtual assistants, chatbots, information retrieval, and language translation.
Top NLPs
We have a list of top NLP that you can utilize in your chatbot. Some popular natural language processing (NLP) libraries and frameworks include:
NLTK (Natural Language Toolkit)
spaCy
Stanford NLP
Gensim
TextBlob
CoreNLP
OpenNLP
FastText
Transformers (such as BERT, GPT, etc.)
AllenNLP
These libraries offer various functionalities for tasks like tokenization, part-of-speech tagging, named entity recognition, sentiment analysis, and more.
