Skip to content

Create basic python bot #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions basic python bot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random

# Define responses for FriendlyBot
responses = {
"hello": "Hello! How can I help you today?",
"how are you": "I'm just a bot, but I'm here to assist you. How can I assist you?",
"goodbye": "Goodbye! Have a great day!",
"default": "I'm not sure what you mean. Can you please rephrase that?",
}

def friendlybot_response(user_input):
user_input = user_input.lower()
# Check if the user input matches any predefined prompts
if user_input in responses:
return responses[user_input]
else:
return responses["default"]

# Main loop for the chatbot
print("FriendlyBot: Hello! I'm here to chat. Type 'goodbye' to exit.")
while True:
user_input = input("You: ")
if user_input.lower() == 'goodbye':
print("FriendlyBot: Goodbye!")
break
response = friendlybot_response(user_input)
print("FriendlyBot:", response)