Learn to build large language model applications: vector databases, langchain, fine tuning and prompt engineering. Learn more


Huda Mahmood - Author
Huda Mahmood
| March 9

AI chatbots are transforming the digital world with increased efficiency, personalized interaction, and useful data insights. While Open AI’s GPT and Google’s Gemini are already transforming modern business interactions, Anthropic AI recently launched its newest addition, Claude 3.

This blog explores the latest developments in the world of AI with the launch of Claude 3 and discusses the relative position of Anthropic’s new AI tool to its competitors in the market.

Let’s begin by exploring the budding realm of Claude 3.


What is Claude 3?

It is the most recent advancement in large language models (LLMs) by Anthropic AI to its claude family of AI models. It is the latest version of the company’s AI chatbot with an enhanced ability to analyze and forecast data. The chatbot can understand complex questions and generate different creative text formats.


Read more about how LLMs make chatbots smarter


Among its many leading capabilities is its feature to understand and respond in multiple languages. Anthropic has emphasized responsible AI development with Claude 3, implementing measures to reduce related issues like bias propagation.


Introducing the members of the Claude 3 family

Since the nature of access and usability differs for people, the Claude 3 family comes with various options for the users to choose from. Each choice has its own functionality, varying in data-handling capabilities and performance.

The Claude 3 family consists of a series of three models called Haiku, Sonnet, and Opus.


Members of the Claude 3 family
Members of the Claude 3 family – Source: Anthropic


Let’s take a deeper look into each member and their specialties.



It is the fastest and most cost-effective model of the family and is ideal for basic chat interactions. It is designed to provide swift responses and immediate actions to requests, making it a suitable choice for customer interactions, content moderation tasks, and inventory management.

However, while it can handle simple interactions speedily, it is limited in its capacity to handle data complexity. It falls short in generating creative texts or providing complex reasonings.



Sonnet provides the right balance between the speed of Haiku and the intelligence of Opus. It is a middle-ground model among this family of three with an improved capability to handle complex tasks. It is designed to particularly manage enterprise-level tasks.

Hence, it is ideal for data processing, like retrieval augmented generation (RAG) or searching vast amounts of organizational information. It is also useful for sales-related functions like product recommendations, forecasting, and targeted marketing.

Moreover, the Sonnet is a favorable tool for several time-saving tasks. Some common uses in this category include code generation and quality control.


Large language model bootcamp



Opus is the most intelligent member of the Claude 3 family. It is capable of handling complex tasks, open-ended prompts, and sight-unseen scenarios. Its advanced capabilities enable it to engage with complex data analytics and content generation tasks.

Hence, Opus is useful for R&D processes like hypothesis generation. It also supports strategic functions like advanced analysis of charts and graphs, financial documents, and market trends forecasting. The versatility of Opus makes it the most intelligent option among the family, but it comes at a higher cost.


Ultimately, the best choice depends on the specific required chatbot use. While Haiku is the best for a quick response in basic interactions, Sonnet is the way to go for slightly stronger data processing and content generation. However, for highly advanced performance and complex tasks, Opus remains the best choice among the three.


Among the competitors

While Anthropic’s Claude 3 is a step ahead in the realm of large language models (LLMs), it is not the first AI chatbot to flaunt its many functions. The stage for AI had already been set with ChatGPT and Gemini. Anthropic has, however, created its space among its competitors.

Let’s take a look at Claude 3’s position in the competition.


Positioning Claude 3 among its competitors – Source: Anthropic


Performance Benchmarks

The chatbot performance benchmarks highlight the superiority of Claude 3 in multiple aspects. The Opus of the Claude 3 family has surpassed both GPT-4 and Gemini Ultra in industry benchmark tests. Anthropic’s AI chatbot outperformed its competitors in undergraduate-level knowledge, graduate-level reasoning, and basic mathematics.

Moreover, the Opus raises the benchmarks for coding, knowledge, and presenting a near-human experience. In all the mentioned aspects, Anthropic has taken the lead over its competition.


Comparing across multiple benchmarks
Comparing across multiple benchmarks – Source: Anthropic

For a deep dive into large language models, context windows, and content augmentation, watch this podcast now!

Data processing capacity

In terms of data processing, Claude 3 can consider much larger text at once when formulating a response, unlike the 64,000-word limit on GPT-4. Moreover, Opus from the Anthropic family can summarize up to 150,000 words while ChatGPT’s limit is around 3000 words for the same task.

It also possesses multimodal and multi-language data-handling capacity. When coupled with enhanced fluency and human-like comprehension, Anthropic’s Claude 3 offers better data processing capabilities than its competitors.


Learn to build LLM applications

Ethical considerations

The focus on ethics, data privacy, and safety makes Claude 3 stand out as a highly harmless model that goes the extra mile to eliminate bias and misinformation in its performance. It has an improved understanding of prompts and safety guardrails while exhibiting reduced bias in its responses.


Which AI chatbot to use?

Your choice relies on the purpose for which you need an AI chatbot. While each tool presents promising results, they outshine each other in different aspects. If you are looking for a factual understanding of language, Gemini is your go-to choice. ChatGPT, on the other hand, excels in creative text generation and diverse content creation.

However, striding in line with modern content generation requirements and privacy, Claude 3 has come forward as a strong choice. Alongside strong reasoning and creative capabilities, it offers multilingual data processing. Moreover, its emphasis on responsible AI development makes it the safest choice for your data.

To sum it up

Claude 3 emerges as a powerful LLM, boasting responsible AI, impressive data processing, and strong performance. While each chatbot excels in specific areas, Claude 3 shines with its safety features and multilingual capabilities. While access is limited now, Claude 3 holds promise for tasks requiring both accuracy and ingenuity. Whether it’s complex data analysis or crafting captivating poems, Claude 3 is a name to remember in the ever-evolving world of AI chatbots.

Ruhma Khawaja author
Ruhma Khawaja
| September 19

The mobile app development industry is in a state of continuous change. With smartphones becoming an extension of our lifestyle, most businesses are scrambling to woo potential customers via mobile apps as that is the only device that is always on our person – at work, at home, or even on a vacation.

COVID-19 had us locked up in our homes for the better part of a year and the mobile started playing an even more important role in our daily lives – grocery haul, attending classes, playing games, streaming on OTT platforms, virtual appointments – all via the smartphone!

Large language model bootcamp

2023: The Year of Innovative Mobile App Trends

Hence, 2023 is the year of new and innovative mobile app development trends. Blockchain for secure payments, augmented reality for fun learning sessions, on-demand apps to deliver drugs home – there’s so much you can achieve with a slew of new technology on the mobile application development front!

A Promising Future: Mobile App Revenue – As per reports by Statista, the total revenue earned from mobile apps is expected to grow at a rate of 9.27% from 2022 to 2026, with a projected market value of 614.40 billion U.S. Dollars by 2026.

What is mobile app technology?

Mobile Application technology refers to various frameworks like (React Native, AngularJS, Laravel, Cake PHP, and so on), tools, components, and libraries that are used to create applications for mobile devices. Mobile app technology is a must-have for reaching a wider audience and making a great fortune in today’s digital-savvy market. The rising apps help businesses to reach more than what they could with a run-of-the-mill website or legacy desktop software.

Importance of mobile app development technologies

Mobile app developers are building everything from consumer-grade apps to high-performing medical solutions, from enterprise solutions to consumer-grade messaging apps in the mobile app industry.

At any stage of development, the developers need to use the latest and greatest technology stack for making their app functional and reliable. This can only be achieved by using the most popular frameworks and libraries that act as a backbone for building quality applications for various platforms like Android, iOS, Windows, etc.


8 mobile app development trends for 2023


Here in this article, we will take a deep dive into the top 9 mobile application trends that are set to change the landscape of mobile app development in 2023!

1. Enhanced 5G Integration:

The rise of 5G technology represents a pivotal milestone in the mobile app development landscape. This revolutionary advancement has unlocked a multitude of opportunities for app creators. With its remarkable speed and efficiency,

5G empowers developers to craft applications that are not only faster but also more data-intensive and reliable than ever before. As we enter 2023, it’s anticipated that developers will make substantial investments in harnessing 5G capabilities to elevate user experiences to unprecedented levels.

2. Advancements in AR and VR:

The dynamic field of mobile app development is witnessing a profound impact from the rapid advancements in Augmented Reality (AR) and Virtual Reality (VR) technologies. These cutting-edge innovations are taking center stage, offering users immersive and interactive experiences.

In the coming year, 2023, we can expect a surge in the adoption of AR and VR by app developers across a diverse range of devices. This trend will usher in a new era of app interactivity, allowing users to engage with digital elements within simulated environments.


Read more –> Predictive analytics vs. AI: Why the difference matters in 2023?


3. Cloud-based applications:

The landscape of mobile app development is undergoing a significant transformation with the emergence of cloud-based applications. This evolution in methodology is gaining traction, and the year 2023 is poised to witness its widespread adoption.

Organizations are increasingly gravitating towards cloud-based apps due to their inherent scalability and cost-effectiveness. These applications offer the advantage of remote data accessibility, enabling streamlined operations, bolstered security, and the agility required to swiftly adapt to evolving requirements. This trend promises to shape the future of mobile app development by providing a robust foundation for innovation and responsiveness.

4. Harnessing AI and Machine Learning:

In the year 2023, the strategic utilization of AI (Artificial Intelligence) and machine learning stands as a game-changing trend, offering businesses a competitive edge. These cutting-edge technologies present an array of advantages, including accelerated development cycles, elevated user experiences, scalability to accommodate growth, precise data acquisition, and cost-effectiveness.

Moreover, they empower the automation of labor-intensive tasks such as testing and monitoring, thereby significantly contributing to operational efficiency.

5. Rise of Low-Code Platforms:

The imminent ascent of low-code platforms is poised to reshape the landscape of mobile app development by 2023. These platforms introduce a paradigm shift, simplifying the app development process substantially. They empower developers with limited coding expertise to swiftly and efficiently create applications.

This transformative trend aligns with the objectives of organizations aiming to streamline their operations and realize cost savings. It is expected to drive the proliferation of corporate mobile apps, catering to diverse business needs.


6. Integration of Chatbots:

Chatbots are experiencing rapid expansion in their role within the realm of mobile app development. They excel at delivering personalized customer support and automating various tasks, such as order processing. In the year 2023, chatbots are poised to assume an even more pivotal role.

Companies are increasingly recognizing their potential in enhancing customer engagement and extracting valuable insights from customer interactions. As a result, the integration of chatbots will be a strategic imperative for businesses looking to stay ahead in the competitive landscape.

Read more —> How to build and deploy custom llm application for your business

7. Mobile Payments Surge:

The year 2023 is poised to witness a substantial surge in the use of mobile payments, building upon the trend’s growing popularity in recent years. Mobile payments entail the seamless execution of financial transactions via smartphones or tablets, ushering in a convenient and secure era of digital transactions.

  • Swift and Secure Transactions: Integrated mobile payment solutions empower users to swiftly and securely complete payments for goods and services. This transformative technology not only expedites financial transactions but also elevates operational efficiency across various sectors.
  • Enhanced Customer Experiences: The adoption of mobile payments enhances customer experiences by eliminating the need for physical cash or credit cards. Users can conveniently make payments anytime, anywhere, contributing to a seamless and user-friendly interaction with businesses.

8. Heightened Security Measures:

In response to the escalating popularity of mobile apps, the year 2023 will witness an intensified focus on bolstering security measures. The growing demand for enhanced security is driven by factors such as the widespread use of mobile devices and the ever-evolving landscape of cybersecurity threats.

  • Stricter Security Policies: Anticipate the implementation of more stringent security policies and safeguards to fortify the protection of user data and privacy. These measures will encompass a comprehensive approach to safeguarding sensitive information, mitigating risks, and ensuring a safe digital environment for users.
  • Staying Ahead of Cyber Threats: Developers and organizations will be compelled to proactively stay ahead of emerging cyber threats. This proactive approach includes robust encryption, multi-factor authentication, regular security audits, and rapid response mechanisms to thwart potential security breaches.

Conclusion: Navigating the mobile app revolution of 2023

As we enter 2023, the mobile app development landscape undergoes significant transformation. With smartphones firmly ingrained in our daily routines, businesses seek to captivate users through innovative apps. The pandemic underscored their importance, from e-commerce to education and telehealth.

The year ahead promises groundbreaking trends:

  • Blockchain Security: Ensuring secure payments.
  • AR/VR Advancements: Offering immersive experiences.
  • Cloud-Based Apps: Enhancing agility and data access.
  • AI & ML: Speeding up development, improving user experiences.
  • Low-Code Platforms: Simplifying app creation.
  • Chatbots: Streamlining customer support.
  • Mobile Payments Surge: Facilitating swift, secure transactions.
  • Heightened Security Measures: Protecting against evolving cyber threats.

2023 not only ushers in innovation but profound transformation in mobile app usage. It’s a year of convenience, efficiency, and innovation, with projected substantial revenue growth. In essence, it’s a chapter in the ongoing mobile app evolution, shaping the future of technology, one app at a time.


Register today

Ruhma Khawaja author
Ruhma Khawaja
| May 19

ChatGPT is the perfect example of innovation that meets profitability. It’s safe to say that artificial intelligence (AI) and ChatGPT are transforming the way the world operates. These technologies are opening up new opportunities for people to make money by creating innovative solutions. From chatbots to virtual assistants and personalized recommendations, the possibilities are endless.

Without a further duo, let’s take a deeper dive into 10 out-of-the-box ideas you can make money with Chat GPT  :

Innovative ways to monetize with Chat GPT
Innovative ways to monetize with Chat GPT

1. AI-Powered Customer Support: 

AI chatbots powered by ChatGPT can provide 24/7 customer support to businesses. This technology can be customized for different industries and can help businesses save money on staffing while improving customer satisfaction. AI-powered chatbots can handle a wide range of customer inquiries, from basic questions to complex issues.

2. Personalized Shopping Bot:

An AI-powered shopping assistant that uses ChatGPT can understand customer preferences and make personalized recommendations. This technology can be integrated into e-commerce websites and can help businesses increase sales and customer loyalty. By analyzing customer data, an AI-powered shopping assistant can suggest products that are relevant to the customer’s interests and buying history.

3. Content Creation:

Using ChatGPT to create automated content for blogs, social media, and other marketing channels can help businesses save time and money while maintaining a consistent content strategy. AI-powered content creation can generate high-quality content that is tailored to the specific needs of the business.

Automated content creation can help you improve your online presence, increase website traffic, and engage with your customers. 

4. Financial Analysis:

Developing an AI-powered financial analysis tool that uses ChatGPT can provide valuable insights and predictions for businesses. This technology can help investors, financial institutions, and businesses themselves make data-driven decisions based on real-time data analysis. 

5. Recruitment Chatbot:

Creating an AI-powered chatbot that uses ChatGPT to conduct initial job interviews for businesses can help save time and resources in the recruitment process. This technology can be customized to ask specific job-related questions and can provide candidates with instant feedback on their interview performance. They can also provide a consistent experience for all candidates, ensuring that everyone receives the same interview questions and process.

6. Virtual Event Platform:

Developing a virtual event platform that uses ChatGPT can help provide personalized recommendations for attendees based on their interests and behavior. This technology can analyze user behavior, preferences, and interaction patterns to make recommendations for sessions, speakers, and networking opportunities. 

7. AI-Powered Writing Assistant:

An AI-powered writing assistant can be created using ChatGPT, which can suggest ideas, improve grammar, and provide feedback on writing. This can be used by individuals, businesses, and educational institutions. The writing assistant can understand the context of the writing and provide relevant suggestions to improve the quality of the content. This can save time for writers and improve the overall quality of their writing.

8. Health Chatbot:

An AI-powered health chatbot can be developed that uses ChatGPT to provide personalized health advice and recommendations. This chatbot can use natural language processing to understand the user’s symptoms, medical history, and other relevant information to provide accurate health advice. It can also provide recommendations for healthcare providers and insurance companies based on the user’s needs. This can be a convenient and cost-effective way for individuals to access healthcare information and advice.

9. Smart Home Automation:

ChatGPT can be used to create a smart home automation system that can understand and respond to voice commands. This system can control lights, temperature, and other devices in the home, making it more convenient and efficient for homeowners. The system can learn the user’s preferences and adjust accordingly, providing a personalized home automation experience. This can also improve energy efficiency by optimizing the use of appliances and lighting.

10. Travel Planning Assistant

An AI-powered travel planning assistant can be created using ChatGPT, which can recommend destinations, activities, and travel itineraries based on the user’s preferences. This can be used by travel companies, individuals, and businesses to create customized travel plans that meet their specific needs. The travel planning assistant can learn the user’s preferences over time and make more accurate recommendations, improving the overall travel experience. This can also save time for users by providing a convenient way to plan travel without the need for extensive research.

In a nutshell

By leveraging AI and ChatGPT, businesses can improve their efficiency, save money on staffing, and provide a better customer experience. This not only helps businesses increase revenue but also strengthens their brand reputation and customer loyalty. 

As AI and ChatGPT continue to evolve, we can expect to see even more innovative ways to use these technologies to make money. The potential impact on the future of business is exciting and it’s an exciting time to be a part of this technological revolution. 


Hudaiba Author
Hudaiba Soomro
| December 14

ChatGPT is being hailed across the globe for disrupting major jobs and businesses. In this blog, we see how much of that hype is fair. 

After raging headlines like “Google is done” and “The college essay is dead”, ChatGPT is busy churning sonnets and limericks about its downtime caused due to heavy traffic. The news spreading like wildfire around town is that it will bring an end to jobs from insurance agents to court reporters. Let’s dive in and assess how much of the hype is true. 


ChatGPT – Data Science Dojo

Did ChatGPT kill the essay? 


OpenAI’s latest release large learning model (LLM), ChatGPT claims to provide natural and conversational communication. It also claims to assist with providing advice, information, performing writing and coding tasks, and admitting mistakes. Naturally, people across the globe have been bombarding the bot with requests to check how great it really is. 


Let’s consider the “death of the college essay“. The first read will show well-written essays to subjects on nearly anything. Consider, for example, the academic essay on theories of nationalism being hailed as a “solid A- essay”. However, a closer look shows that this AI tool works by using existing templates and so, college essays are churned out as per five-paragraph formulas.  


chatgpt essay
ChatGPT essay


These academic essays also lack the sophistication provided by critical thinking skills. They reproduce existing content online and refashion it to fit a specific template. In style, they are dreadfully dull, lacking stylistic human expressions.

Similarly, ChatGPT’s poetic output conveys a similar emulation of formulas being rewired, with technical obeyance of rhyme scheme, while a lack of ingenuity is evident.  


An obvious conclusion, then, appears that, while great at reorganizing text to fit templates, is deeply unaware of what it means. This comes as no surprise to those familiar with even a rudimentary understanding of natural language processing and its applications.

The function of large learning models (LLM) is far from epistemological and is rather based on identifying patterns and replicating them.  


Chatgpt Sonnet
ChatGPT sonnet



Here, it should be noted that AI tools such as it can be used as tools for humans to perform routinized, well-formulated tasks such as producing well-structured poetry or college essays. However, they lack the essential key insights provided via human intelligence regardless of the field of study. 


Is ChatGPT a source of information or misinformation? 


A feature that allows ChatGPT’s performance across a range of writing tasks is its ability to fast-fetch information. Because of its ability to fetch information immediately, it is being hailed as the end of Google. However, a few considerations regarding the differences between large learning models and search engines are important. 

For example, search engines work by hunting the web for all weblinks that are related to the search query. Their selling point here is accuracy, as they only connect you to other sources. ChatGPT, however, can provide responses to nearly any nonsensical queries.

Consider, for example, a user’s search query on designing “an electron app that is hosted on a remote server to give a desktop user notification.” As a response to this query, it came up with a completely fake method, revealing ChatGPT’s susceptibility to being a source of misinformation. 


chatgpt answer
ChatGPT answer


This tool would only admit to mistakes if prompted to do so via further inquiry, making it a rather risky tool. Opposed to this, an SEO engine would provide accurate information from original sources. This ranks the practical utility of an SEO engine far above it. This settles the debate on whether ChatGPT is to replace Google any time soon.  


Furthermore, ChatGPT’s ability to construct nonsensical ideas and arguments about nearly anything can make it unsafe for a first onlooker. Only a trained eye will then be capable of nitpicking factually plausible ideas from the mere fictional constructs. Here, again, the relevance of human ingenuity and intelligence is needed to ensure tools like this, are used in meaningful ways.  


ChatGPT’s release a signal to rethink education 


ChatGPT’s advances are, however, relevant in considering the value of human creative output rethinking conventional education and training at schools that rely on memorizing and reproducing routine tasks. For circumstances where these tasks or skills are deemed essential, it’s simple to enforce testing practices that prevent access to such sources.  


At the same time, it’s an unfair stretch to suggest that ChatGPT means the end of optimized search engines like Google and creative human tasks such as writing. At best, it can be used to assist humans in their projects, be it their daily tasks or work-related queries.

It is, at the end of the day, only a mere tool that can be integrated in a plethora of human initiatives.  


Final words 

With limitations ranging from verbosity in communication, inaccurate information, and an obvious lack of sophisticated opinions, ChatGPT’s performance doesn’t quite meet the hype. Similarly, instead of offering natural conversations, ChatGPT has offered boring and dull essays, even when it comes to imitating a writer’s style.

At the same time, it is a tool that can be used by trained experts to perform certain routine tasks including writing, coding, and information fetching more easily. 


Data Science Dojo
Umair Hasan
| September 26

In this tutorial, you will learn how to create an attractive voice-controlled python chatbot application with a small amount of coding. To build our application we’ll first create a good-looking user interface through the built-in Tkinter library in Python and then we will create some small functions to achieve our task. 


Here is a sneak peek of what we are going to create. 


Voice controlled chatbot
Voice controlled chatbot using coding in Python – Data Science Dojo

Before kicking off, I hope you already have a brief idea about web scraping, if not then read the following article talking about Python web scraping 


PRO-TIP: Join our 5-day instructor-led Python for Data Science training to enhance your deep learning


Pre-requirements for building a voice python chatbot

Make sure that you are using Python 3.8+ and the following libraries are installed on it 

  • Pyttsx3 (pyttsx3 is a text-to-speech conversion library in Python) 
  • SpeechRecognition (Library for performing speech recognition) 
  • Requests (The requests module allows you to send HTTP requests using Python) 
  • Bs4 (Beautiful Soup is a library that is used to scrape information from web pages) 
  • pyAudio (With PyAudio, you can easily use Python to play and record audio) 


If you are still facing installation errors or incompatibility errors, then you can try downloading specific versions of the above libraries as they are tested and working currently in the application. 


  • Python 3.10 
  • pyttsx3==2.90 
  • SpeechRecognition==3.8.1 
  • requests==2.28.1
  • beautifulsoup4==4.11.1 
  • beautifulsoup4==4.11.1 


Now that we have set everything it is time to get started. Open a fresh new py file and name it VoiceChatbot.py. Import the following relevant libraries on the top of the file. 


  • from tkinter import * 
  • import time
  • import datetime
  • import pyttsx3
  • import speech_recognition as sr
  • from threading import Thread
  • import requests
  • from bs4 import BeautifulSoup 


The code is divided into the GUI section, which uses the Tkinter library of python and 7 different functions. We will start by declaring some global variables and initializing instances for text-to-speech and Tkinter. Then we start creating the windows and frames of the user interface. 


The user interface 

This part of the code loads images initializes global variables, and instances and then it creates a root window that displays different frames. The program starts when the user clicks the first window bearing the background image. 


if __name__ == “__main__”: 


#Global Variables 

loading = None
query = None
flag = True
flag2 = True


#initalizng text to speech and setting properties 

engine = pyttsx3.init() # Windows voices = engine.getProperty('voices') engine.setProperty('voice', voices[1].id) rate = engine.getProperty('rate') engine.setProperty('rate', rate-10) 


#loading images 

    img1= PhotoImage(file='chatbot-image.png') 
    img2= PhotoImage(file='button-green.png') 
    img3= PhotoImage(file='icon.png') 
    img4= PhotoImage(file='terminal.png') 
    front_image = PhotoImage(file="front2.png") 


#creating root window 

    root.title("Intelligent Chatbot") 


#Placing frame on root window and placing widgets on the frame 

    f = Frame(root,width = 1360, height = 690) 


#first window which acts as a button containing the background image 

    okVar = IntVar() 
    btnOK = Button(f, image=front_image,command=lambda: okVar.set(1)) 
    background_label = Label(root, image=background_image) 
    background_label.place(x=0, y=0) 


#Frame that displays gif image 

    frames = [PhotoImage(file='chatgif.gif',format = 'gif -index %i' %(i)) for i in range(20)] 
    canvas = Canvas(root, width = 800, height = 596) 
    canvas.create_image(0, 0, image=img1, anchor=NW) 


#Question button which calls ‘takecommand’ function 

    question_button = Button(root,image=img2, bd=0, command=takecommand) 


#Right Terminal with vertical scroll 

    canvas2.config(width=500,height=596, background="black") 
    canvas2.create_image(0,0, image=img4, anchor="nw") 
    task = Thread(target=main_window) 


The main window functions 

This is the first function that is called inside a thread. It first calls the wishme function to wish the user. Then it checks whether the query variable is empty or not. If the query variable is empty, then it checks the contents of the query variable. If there is a shutdown or quit or stop word in query, then it calls the shutdown function, and the program exits. Else, it calls the web_scraping function. This function calls another function with the name wishme. 


def main_window(): 
    global query 
    while True: 
        if query != None: 
            if 'shutdown' in query or 'quit' in query or 'stop' in query or 'goodbye' in query: 
                query = None 


The wish me function 

This function checks the current time and greets users according to the hour of the day and it also updates the canvas. The contents in the text variable are passed to the ‘speak’ function. The ‘transition’ function is also invoked at the same time in order to show the movement effect of the bot image, while the bot is speaking. This synchronization is achieved through threads, which is why these functions are called inside threads. 


def wishme(): 
    hour = datetime.datetime.now().hour 
    if 0 <= hour < 12: 
        text = "Good Morning sir. I am Jarvis. How can I Serve you?" 
    elif 12 <= hour < 18: 
        text = "Good Afternoon sir. I am Jarvis. How can I Serve you?" 
        text = "Good Evening sir. I am Jarvis. How can I Serve you?" 
    canvas2.create_text(10,10,anchor =NW , text=text,font=('Candara Light', -25,'bold italic'), fill="white",width=350) 
    p2 = Thread(target=transition) 


The speak function 

This function converts text to speech using pyttsx3 engine. 

def speak(text): 
    global flag 


The transition functions 

The transition function is used to create the GIF image effect, by looping over images and updating them on canvas. The frames variable contains a list of ordered image names.  


def transition(): 
    global img1 
    global flag 
    global flag2 
    global frames 
    global canvas 
    local_flag = False 
    for k in range(0,5000): 
        for frame in frames: 
            if flag == False: 
                canvas.create_image(0, 0, image=img1, anchor=NW) 
                flag = True 
                canvas.create_image(0, 0, image=frame, anchor=NW) 


The web scraping function 

This function is the heart of this application. The question asked by the user is then searched on google using the ‘requests’ library of python. The ‘beautifulsoap’ library extracts the HTML content of the page and checks for answers in four particular divs. If the webpage does not contain any of the four divs, then it searches for answers on Wikipedia links, however, if that is also not successful, then the bot apologizes.  


def web_scraping(qs): 
    global flag2 
    global loading 
    URL = 'https://www.google.com/search?q=' + qs 
    page = requests.get(URL) 
    soup = BeautifulSoup(page.content, 'html.parser') 
    div0 = soup.find_all('div',class_="kvKEAb") 
    div1 = soup.find_all("div", class_="Ap5OSd") 
    div2 = soup.find_all("div", class_="nGphre") 
    div3  = soup.find_all("div", class_="BNeawe iBp4i AP7Wnd") 

    links = soup.findAll("a") 
    all_links = [] 
    for link in links: 
       link_href = link.get('href') 
       if "url?q=" in link_href and not "webcache" in link_href: 

    flag= False 
    for link in all_links: 
       if 'https://en.wikipedia.org/wiki/' in link: 
           wiki = link 
           flag = True 
    if len(div0)!=0: 
        answer = div0[0].text 
    elif len(div1) != 0: 
       answer = div1[0].text+"\n"+div1[0].find_next_sibling("div").text 
    elif len(div2) != 0: 
       answer = div2[0].find_next("span").text+"\n"+div2[0].find_next("div",class_="kCrYT").text 
    elif len(div3)!=0: 
        answer = div3[1].text 
    elif flag==True: 
       page2 = requests.get(wiki) 
       soup = BeautifulSoup(page2.text, 'html.parser') 
       title = soup.select("#firstHeading")[0].text
       paragraphs = soup.select("p") 
       for para in paragraphs: 
           if bool(para.text.strip()): 
               answer = title + "\n" + para.text 
        answer = "Sorry. I could not find the desired results"
    canvas2.create_text(10, 225, anchor=NW, text=answer, font=('Candara Light', -25,'bold italic'),fill="white", width=350) 
    flag2 = False 
    p2 = Thread(target=transition) 


The take command function 

This function is invoked when the user clicks the green button to ask any question. The speech recognition library listens for 5 seconds and converts the audio input to text using google recognize API. 


def takecommand(): 
    global loading 
    global flag 
    global flag2 
    global canvas2 
    global query 
    global img4 
    if flag2 == False: 
        canvas2.create_image(0,0, image=img4, anchor="nw")  
    speak("I am listening.") 
    flag= True 
    r = sr.Recognizer() 
    r.dynamic_energy_threshold = True 
    r.dynamic_energy_adjustment_ratio = 1.5 
    #r.energy_threshold = 4000 
    with sr.Microphone() as source: 
        #r.pause_threshold = 1 
        audio = r.listen(source,timeout=5,phrase_time_limit=5) 
        #audio = r.listen(source) 
        query = r.recognize_google(audio, language='en-in') 
        print(f"user Said :{query}\n") 
        query = query.lower() 
        canvas2.create_text(490, 120, anchor=NE, justify = RIGHT ,text=query, font=('fixedsys', -30),fill="white", width=350) 
        global img3 
        loading = Label(root, image=img3, bd=0) 
        loading.place(x=900, y=622) 
    except Exception as e: 
        speak("Say that again please") 
        return "None"


The shutdown function 

This function farewells the user and destroys the root window in order to exit the program. 

def shut_down(): 
    p1=Thread(target=speak,args=("Shutting down. Thankyou For Using Our Sevice. Take Care, Good Bye.",)) 
    p2 = Thread(target=transition) 



It is time to wrap up, I hope you enjoyed our little application. This is the power of Python, you can create small attractive applications in no time with a little amount of code. Keep following us for more cool python projects! 


Code - CTA


Data Science Dojo
Guest Author

In the second article of this chatbot series, learn how to build a rule-based chatbot and discuss their business applications.

Chatbots have surged in popularity, becoming pivotal in text-based customer interactions, especially in support services. It’s expected that nearly 25% of customer service operations will use them by 2020.

In the first part of A Beginners Guide to Chatbotswe discussed what chatbots were, their rise to popularity, and their use cases in the industry. We also saw how the technology has evolved over the past 50 years.


In this second part of the series, we’ll take you through the process of building a simple Rule-based chatbot in Python. Before we start with the tutorial, we need to understand the different types of chatbots and how they work.

Types of chatbots

Chatbots can be classified into two different types based on how they are built:

Rule-based Chatbots

Rule-based chatbots are pretty straightforward. They use a predefined response database and follow set rules to determine appropriate replies. Although they can’t generate answers independently, their effectiveness hinges on the depth of the response database and the efficiency of their rules.

The simplest form of Rule-based Chatbots has one-to-one tables of inputs and their responses. These bots are extremely limited and can only respond to queries if they are an exact match with the inputs defined in their database.

AI-based chatbots

With the rise in the use of machine learning in recent years, a new approach to building chatbots has emerged. With the use of artificial intelligence, creating extremely intuitive and precise chatbots tailored to specific purposes has become possible.

Unlike their rule-based kin, AI-based chatbots are based on complex machine-learning models that enable them to self-learn.


Libraries for building a rule-based chatbot


Now that we’re familiar with how chatbots work, we’ll be looking at the libraries that will be used to build our simple Rule-based Chatbot.

Natural Language Toolkit (NLTK)


Natural Language Toolkit is a Python library that makes it easy to process human language data. It provides easy-to-use interfaces to many language-based resources such as the Open Multilingual Wordnet, and access to a variety of text-processing libraries.

Regular Expression (RegEx) in Python


regular expression is a special sequence of characters that helps you search for and find patterns of words/sentences/sequences of letters in sets of strings, using a specialized syntax. They are widely used for text searching and matching in UNIX.


Python includes support for regular expression through the re package.

Want to upgrade your Python abilities? Check out Data Science Dojo’s Introduction to Python for Data Science.

Building a rule-based chatbot


This very simple rule-based chatbot will work by searching for specific keywords in user input. The keywords will help determine the desired action of the user (user’s intent). Once the intent is identified, the bot will pick out an appropriate response.


Role of intent in a rule-based chatbot
Role of intent in a rule-based chatbot

The list of keywords and a dictionary of responses will be built up manually based on the specific use case for the chatbot.

We’ll be designing a very simple chatbot for a bank that can respond to greetings (Hi, Hello, etc.) and answer questions about the bank’s hours of operation.

A flow of how the chatbot would process inputs is shown below:


Python rule-based chatbot process
The flow of input requests by a chatbot


We will be following the steps below to build our chatbot


  1. Importing Dependencies
  2. Building the Keyword List
  3. Building a dictionary of Intents
  4. Defining a dictionary of responses
  5. Matching Intents and Generating Responses

Importing dependencies


First, we will import needed the packages/libraries. The re package handles regular expressions in Python. We’ll also use WordNet from NLTK, a lexical database that defines semantic relationships between words, to build a dictionary of synonyms for our keywords. This will expand our list of keywords without manually introducing every possible word a user could use.


# Importing modules
import re
from nltk.corpus import wordnet

Building a list of keywords


Once we have imported our libraries, we’ll need to build up a list of keywords that our chatbot will look for. This list can be as exhaustive as you want. The more keywords you have, the better your chatbot will perform.


As discussed previously, we’ll be using WordNet to build up a dictionary of synonyms to our keywords. For details about how WordNet is structured, visit their website.



# Building a list of Keywords
for word in list_words:
    for syn in wordnet.synsets(word):
        for lem in syn.lemmas():
            # Remove any special characters from synonym strings
            lem_name = re.sub('[^a-zA-Z0-9 \n\.]', ' ', lem.name())
print (list_syn)




{'hello', 'howdy', 'hi', 'hullo', 'how do you do'}
{'time', 'clock', 'timing'}


Here, we first defined a list of words list_words that we will be using as our keywords. We used WordNet to expand our initial list with synonyms of the keywords. This list of keywords is stored in list_syn.


New keywords can simply be added to list_words. The chatbot will automatically pull their synonyms and add them to the keywords dictionary. You can also edit list_syn directly if you want to add specific words or phrases that you know your users will use.

Building a dictionary of intents


Once our keywords list is complete, we need to build up a dictionary that matches our keywords to intents. We also need to reformat the keywords in a special syntax that makes them visible to Regular Expression’s search function.



# Building dictionary of Intents & Keywords
# Defining a new key in the keywords dictionary
# Populating the values in the keywords dictionary with synonyms of keywords formatted with RegEx metacharacters 
for synonym in list(list_syn['hello']):

# Defining a new key in the keywords dictionary
# Populating the values in the keywords dictionary with synonyms of keywords formatted with RegEx metacharacters 
for synonym in list(list_syn['timings']):
for intent, keys in keywords.items():
    # Joining the values in the keywords dictionary with the OR (|) operator updating them in keywords_dict dictionary
print (keywords_dict)



{'greet': re.compile('.*\\bhello\\b.*|.*\\bhowdy\\b.*|.*\\bhi\\b.*|.*\\bhullo\\b.*|.*\\bhow-do-you-do\\b.*'), 'timings': re.compile('.*\\btime\\b.*|.*\\bclock\\b.*|.*\\btiming\\b.*')}


The updated and formatted dictionary is stored in keywords_dict. The intent is the key and the string of keywords is the value of the dictionary.


Let’s look at one key-value pair of the keywords_dict dictionary to understand the syntax of Regular Expression;

{'greet': re.compile('.*\\bhullo\\b.*|.*\\bhow-do-you-do\\b.*|.*\\bhowdy\\b.*|.*\\bhello\\b.*|.*\\bhi\\b.*')
 Regular Expression uses specific patterns of special Meta-Characters to search for strings or sets of strings in an expression.


Since we need our chatbot to search for specific words in larger input strings we use the following sequences of meta-characters:




In this specific sequence, the keyword (hullo) is encased between a \b sequence. This tells the RegEx Search function that the search parameter is the keyword (hullo).


The first sequence \bhullo\b is encased between a period star .* sequence. This sequence tells the RegEx Search function to search the entire input string from beginning to end for the search parameter (hullo).


In the dictionary, multiple such sequences are separated by the OR | operator. This operator tells the search function to look for any of the mentioned keywords in the input string.


More details about Regular Expression and its syntax can be found here. You can add as many key-value pairs to the dictionary as you want to increase the functionality of the chatbot.

Defining responses


The next step is defining responses for each intent type. This part is very straightforward. The responses are described in another dictionary with the intent being the key.


We’ve also added a fallback intent and its response. This is a fail-safe response in case the chatbot is unable to extract any relevant keywords from the user input.



# Building a dictionary of responses
    'greet':'Hello! How can I help you?',
    'timings':'We are open from 9AM to 5PM, Monday to Friday. We are closed on weekends and public holidays.',
    'fallback':'I dont quite understand. Could you repeat that?',

Matching intents and generating responses


Now that we have the back end of the chatbot completed, we’ll move on to taking input from the user and searching the input string for our keywords.


We use the RegEx Search function to search the user input for keywords stored in the value field of the keywords_dict dictionary.  If you recall, the values in the keywords_dict dictionary were formatted with special sequences of meta-characters.


RegEx’s search function uses the sequences to compare the character patterns in the keywords with the input string. If a match is found, the current intent is selected and used as a key to the responses dictionary to select the correct response.



print ("Welcome to MyBank. How may I help you?")
# While loop to run the chatbot indefinetely
while (True):  
    # Takes the user input and converts all characters to lowercase
    user_input = input().lower()
    # Defining the Chatbot's exit condition
    if user_input == 'quit': 
        print ("Thank you for visiting.")
    matched_intent = None 
    for intent,pattern in keywords_dict.items():
        # Using the regular expression search function to look for keywords in user input
        if re.search(pattern, user_input): 
            # if a keyword matches, select the corresponding intent from the keywords_dict dictionary
    # The fallback intent is selected by default
    if matched_intent in responses:
        # If a keyword matches, the fallback intent is replaced by the matched intent as the key for the responses dictionary
        key = matched_intent
    # The chatbot prints the response that matches the selected intent
    print (responses[key]) 


The chatbot picked the greeting from the first user input (‘Hi’) and responded according to the matched intent.

The same happened when it located the word (‘time’) in the second user input.

The third user input (‘How can I open a bank account’) didn’t have any keywords that were present in Bankbot’s database so it went to its fallback intent.

You can add multiple keywords/phrases/sentences and intents to build a robust chatbot for human interaction.

Building chatbot in Python – the next step


This blog was a hands-on introduction to building a basic chatbot in Python. We only worked with 2 intents in this tutorial for simplicity. You can easily expand the functionality of this chatbot by adding more keywords, intents, and responses.


Building a rule-based chatbot is a laborious process, especially in a business environment where it requires increased complexity. It makes rule-based chatbots impractical for enterprises due its limited conversational capabilities. AI-based Chatbots are a more practical solution for real-world scenarios.


In the next blog in the series, we’ll learn how to build a simple AI-based Chatbot in Python.

Do you want to learn more about machine learning and its applications? Check out Data Science Dojo’s online data science certificate program!

Data Science Dojo
Usman Shahid
| September 15

Explore Google DialogFlow, a conversational AI Platform and use it to build a smart, contextually aware Chatbot.

Chatbots have become extremely popular in recent years and their use in the e-commerce industry has skyrocketed. They have found a strong foothold in almost every task that requires text-based public dealing. They have become so critical with customer support, for example that almost 25% of all customer service operations are expected to use them by the end of 2020.

Building a comprehensive and production-ready chatbot from scratch, however, is an almost impossible task. Tech companies like Google and Amazon have been able to achieve this feat after spending years and billions of dollars in research, something that not everyone with a use for a chatbot can afford.

Luckily, almost every player in the tech market (including Google and Amazon) allows businesses to purchase their technology platforms to design customized chatbots for their own use. These platforms have pre-trained language models and easy-to-use interfaces that make it extremely easy for new users to set up and deploy customized chatbots in no time.

In the previous blogs in our series on chatbots, we talked about how to build AI and rule based chatbots in Python. In this blog, we’ll be taking you through how to build a simple AI chatbot using Google’s DialogFlow:

Intro to Google DialogFlow

DialogFlow is a natural language understanding platform (based on Google’s AI) that makes it easy to design and integrate a conversational user interface into your mobile app, web application, device, bot, interactive voice response system, and so on. Using DialogFlow, you can provide new and engaging ways for users to interact with your product.

Fundamentals of DialogFlow

We’re going to run through some of the basics of DialogFlow just so that you understand the vernacular when we build our chatbot.

PRO TIP: Join our data science bootcamp program today to enhance your NLP skills!


An Agent is what DialogFlow calls your chatbot. A DialogFlow Agent is a trained generative machine learning model that understands natural language flows and the nuances of human conversations. DialogFlow translates input text during a conversation to structured data that your apps and services can understand.


Intents are the starting point of a conversation in DialogFlow. When a user starts a conversation with a chatbot, DialogFlow matches the input to the best intent available.

A chatbot can have as many intents as required depending on the level of conversational detail a user wants the bot to have. Each intent has the following parameters:

  • Training Phrases: These are examples of phrases your chatbot might receive as inputs. When a user input matches one of the phrases in the intent, that specific intent is called. Since all DialogFlow agents use machine learning, you don’t have to define every possible phrase your users might use. DialogFlow automatically learns and expands this list as users interact with your bot.
  • Parameters: These are input variables extracted from a user input when a specific intent is called. For example, a user might say: “I want to schedule a haircut appointment on Saturday.” In this situation, “haircut appointment” and “Saturday” could be the possible parameters DialogFlow would extract from the input. Each parameter has a type, like a data type in normal programming, called an Entity. You need to define what parameters you would be expecting in each intent. Parameters can be set to “required”. If a required parameter is not present in the input, DialogFlow will specifically ask the user for it.
  • Responses: These are the responses DialogFlow returns to the users when an Intent is matched. They may provide answers, ask the user for more information or serve as conversation terminators.


Entities are information types of intent parameters which control how data from an input is extracted. They can be thought of as data types used in programming languages. DialogFlow includes many pre-defined entity types corresponding to common information types such as dates, times, days, colors, email addresses etc.

You can also define custom entity types for information that may be specific to your use case. In the example shared above, the “appointment type” would be an example of a custom entity.


DialogFlow uses contexts to keep track of where users are in a conversation. During the flow of a conversation, multiple intents may need to be called. DialogFlow uses contexts to carry a conversation between them. To make an intent follow on from another intent, you would create an output context from the first intent and place the same context in the input context field of the second intent.

In the example shared above, the conversation might have flowed in a different way.

In this specific conversation, the agent is performing 2 different tasks: authentication and booking.

When the user initiates the conversation, the Authentication Intent is called that verifies the user’s membership number. Once that has been verified, the Authentication Intent activates the Authentication Context and the Booking Intent is called.

In this situation, the Booking Intent knows that the user is allowed to book appointments because the Authentication Context is active. You can create and use as many contexts as you want in a conversation for your use case.

Conversation in a DialogFlow hatbot

A conversation with a DialogFlow Agent flows in the following way:

Chatbot Conversation Text
An example of DialogFlow Chatbot Conversation

Building a chatbot

In this tutorial, we’ll be building a simple customer services agent for a bank. The chatbot (named BankBot) will be able to:

  1. Answer Static Pre-Defined Queries
  2. Set up an appointment with a Customer Services Agent

Creating a new DialogFlow agent

It’s extremely easy to get started with DialogFlow. The first thing you’ll need to do is log in to DialogFlow. To do that, go to https://dialogflow.cloud.google.com and login with your Google Account (or create one if you don’t have it).

Once you’re logged in, click on ‘Create Agent’ and give it a name.

DialogFlow Interface

1. Answering static defined series

To keep things simple, we’ll be focusing on training BankBot to respond to one static query initially; responding to when a user asks the Bank’s operational timings. For this we will teach BankBot a few phrases that it might receive as inputs and their corresponding responses.

Creating an intent

The first thing we’ll do is create a new Intent. That can be done by clicking on the ‘+’ sign next to the ‘Intents’ tab on the left side panel. This intent will specifically be for answering queries about our bank’s working hours. Once on the ‘Create Intent’ Screen (as shown below), fill in the ‘Intent Name’ field.

Text Fields
Intent Name Fields

Training phrases

Once the intent is created, we need to teach BankBot what phrases to look for. A list of sample phrases needs to be entered under ‘Training Phrases’. We don’t need to enter every possible phrase as BankBot will keep on learning from the inputs it receives thanks to Google’s machine learning.

Training Phrases
Adding Training Phrases


After the training phrases, we need to tell BankBot how to respond if this intent is matched. Go ahead and type in your response in the ‘Responses’ field.

Building a Google DialogFlow Chatbot | Data Science Dojo

DialogFlow allows you to customize your responses based on the platform (Google Assistant, Facebook Messenger, Kik, Slack etc.) you will be deploying your chatbot on.

Once you’re happy with the response, go ahead and save the Intent by clicking on the Save button at the top.

Training Phrases
Training Phrases with Actions and Parameters

Testing the intent

Once you’ve saved your intent, you can see how its working right within DialogFlow.

To test BankBot, type in any user query in the text box labeled ‘Try it Now’.

Testing Phase
Testing the Intent Example

2. Setting an appointment

Getting BankBot to set an appointment is mostly the same as answering static queries, with one extra step. To book an appointment, BankBot will need to know the date and time the user wants the appointment for. This can be done by teaching BankBot to extract this information from the user query – or to ask the user for this information in-case it is not provide in the initial query.

Creating an intent

This process will be the same as how we created an intent in the previous example.

Training phrases

This will also be same as in the previous example except for one important difference.  In this situation, there are 3 distinct ways in which the user can structure his initial query:

  1. Asking for an appointment without mentioning the date or time in the initial query.
  2. Asking for an appointment with just the date mentioned in the initial query.
  3. Asking for an appointment with both the date and time mentioned in the initial query.

We’ll need to make sure to add examples of all 3 cases in our Training Phrases.  We don’t need to enter every possible phrase as BankBot will keep on learning from the inputs it receives.

Training Phrases
Adding Training Phrases


BankBot will need additional information (the date and time) to book an appointment for the user. This can be done by defining the date and time as ‘Parameters’ in the Intent.

For every defined parameter, DialogFlow requires the following information:

  1. Required: If the parameter is set to ‘Required’, DialogFlow will prompt the user for information if it has not been provided in the original query.
  2. Parameter Name: Name of the parameter.
  3. Entity: The type of data/information that will be stored in the parameter.
  4. Value: The variable name that will be used to reference the value of this parameter in ‘Responses.’
  5. Prompts: The response to be used in-case the parameter has not been provided in the original query.
Actions parameters dialog box
Adding Actions and Parameters

DialogFlow automatically extracts any parameters it finds in user inputs (notice that the time and date information in the training phrases has automatically been color-coded according to the parameters).


After the training phrases, we need to tell BankBot how to respond if this intent is matched. Go ahead and type in your response in the ‘Responses’ field.

responses dialog box
Adding Text Responses

DialogFlow allows you to customize your responses based on the platform (Google Assistant, Facebook Messenger, Kik, Slack etc.) you will be deploying your chatbot on.
Once you’re happy with the response, go ahead and save the Intent by clicking on the Save button at the top.

Testing the intent

Once you’ve saved your intent, you can see how its working right within DialogFlow.

To test BankBot, type in any user query in the text box labeled ‘Try it Now’

Example 1: All parameters present in the initial query.

Text box
An Example of Testing an Intent

Example 2: When complete information is not present in the initial query.

Some Text
DialogFlow Chatbot Conversation Example


DialogFlow has made it exceptionally easy to build extremely functional and fully customizable chatbots with little effort. The purpose of this tutorial was to give you an introduction to building chatbots and to help you get familiar with the foundational concepts of the platform.

Other Conversational AI tools use almost the same concepts as were discussed, so these should be transferable to any platform.

Related Topics

Machine Learning
Generative AI
Data Visualization
Data Security
Data Science
Data Engineering
Data Analytics
Computer Vision
Artificial Intelligence