Skip to content
Bertoldas Cepulis (cepulisb) edited this page Nov 29, 2018 · 1 revision

CHATBOT PROJECT

INTRODUCTION

Our team bot was created to do multifunctional exercises such as:

  • chating with bot in natural language
  • getting the weather in any locations
  • taking video form youtube
  • getting jokes from huge library in the internet

CHOOSING DISCORD

The bot was created in discord app which was the best choice for our team.

As a result we gained easy communication throught the team and it was extremely easy to demonstrate our chatbots and progress each week.

MY PART IN THE TEAM

In the beginning it was hard for me to get used to discord and creating the bot because other team members was already had a bit of practice with it and for me it was the first time.

STARTING

For the beginning I started with creating my own bot which was not that hard when the internet is full of information how to do it. For the beginning I choosed the YOUTUBE video which also helped me to write first code.

EXAMPLE OF MY FIRST CODE

def check_for_emoji(self, sentence):
        if sentence == "crying":
            return (":joy:")
        if sentence == "cool":
            return (":sunglasses:")
        if sentence == "ok":
            return (":ok_hand:")
        if sentence == "USA":
            return (":flag_um:")
        if sentence == "UK":
            return (":flag_gb:")
        if sentence == "really bad":
            return (":poop:")
        if sentence == "lithuania":
            return (":flag_lt:")
        if sentence == "kiss":
            return (":kissing_heart:")
        if sentence == "happy":
            return (":smiley:")
        if sentence == "angry":
            return ( ":imp:")
        if sentence == "cookie":
            return (":cookie:")

emoji example

REAL WORK

After few tests with the team we considered to create NLP.

At first we tried a bit with Rasa_NLU but then we started to create it form the scratch. There my suffer started.

For the first steps I needed to create keywords for my bot that he could understand for what he should answer.

EXAMPLE OF THE KEYWORDS

GREETING_KEYWORDS = ("hello", "hi", "greetings", "sup",  "good evening","good morning","helo", "bonjour", )

GREETING_RESPONSES = ["'sup bro", "hey", "good morning", "hello"]



DOING_KEYWORDS = ("how are you doing?", "how are you?")

DOING_RESPONSES =  ["I'am doing great","I'm doing fine","I'm alright","I'm doing terrible", "I'm doing really bad","I'm doing bad"] 

ASKING_ABOUT_YOU = ["And what about you?", "how bout you?","what about you?", "and you?"]

JOKES_KEYWORDS = ["give me jokes", "joke", "can u give me joke?", "can u give me jokes?","can you please give me some jokes?", "jokes"]

So I done this just because when you write something for the bot and if your word is the same as input words then the bot replay for you with given outcome words There I used lists for outcome words and tuples for the income words.

PROBLEMS

As in all codes we have some problems there I have them as well.

The first problem with which we encountered was that the bot was reading my GREETING_KEYWORDS as a one word so for example if the KEYWORD was "GOOD EVENING" bot only readed the good and he was not replaying anything, or we needed to change everything including GREETING_KEYWORDS like this.

mistake

So I founded that the function parameters was wrong because in

``` def check_for_greeting(self, snetence)

I was using not the sentence but the word so after that changes the code was working pretty fine.

Working along I found another small problem where the bot was replaying to its own messages which caused that

photo

WHAT IS NEXT?

Later on I started with the actuall code

EXAMPLE OF THE NLU BOT CODE

def check_for_greeting(self, sentence):
        """if user write anything from  the greeting keyword, the bot response with greeting response"""
        if sentence.lower() in GREETING_KEYWORDS:
            return random.choice(GREETING_RESPONSES)
        if sentence.lower() in DOING_KEYWORDS:
            return random.choice(DOING_RESPONSES) + ", " + random.choice(ASKING_ABOUT_YOU)

There we take sentence which is wrote by the user and we use sentence.lower just to prevent our code if the user is writing with the CAPS LOCK.

Later we are checking the input words and if we recognise some from our GREETING_KEYWORDS than bot replays to the user with random response from GREETING_RESPONCES also we do this the same with the DOING_KEYWORDS and DOING_RESPONCES, but there we just add one more step in which bot asks about how the user is doing.

OUT OF MY COMFORT ZONE

For my next code I really needed to get out of my comfort zone and do what makes me a bit sick. I was reading a lot of pages how to use API but after two days of trying I give up.

After considering I found how to use API in a bit easier way so I came along with some code

API CODE EXAMPLE

def check_for_jokes(self, sentence):
        r = requests.get('https://api.icndb.com/jokes/random')
        data = r.json()
        ans = data["value"]["joke"]
        if sentence.lower() in JOKES_KEYWORDS:
            return ans

THE TEAM

Our team had amazing scrum master Declan Soper which had a lot of useful knowledge in team managing which helped us a lot.

MEMBERS

The team was not that great, but it happens in real world so we had to deal with this problem.

One member quit the group or he was just not walking to the lectures another two was attending to some of the lectures but they was not working with the team and the communication with them was extremely hard. So we actually had the three members in our team.

WORKING WITH TEAM

At the team meetings we used team planning throught azure where at first we created a lots of files what we want to do for our team chatbot lately we attached the work for every team member

To make our work faster and easier we did planning poker every week which helped us to consider how much time we will waste on different chatbot codes.

Also we used github which helped to combine our codes together and also to have our codes anywhere we go.