Python Forum
Python Automated Response System Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Automated Response System Help
#1
Hi there everyone. I am new to python and I just wanted to know how it would be possible to generate different responses within this code depending on what I input.

Basically what I need to happen is when I input "I Lost My License", or "Problem Saving File" into the subject of the email.

I need it to output:

Dear [email protected],
Thank you for contacting our company. You will be contacted via email
to verify your license request.
Thank you,
Company Customer Service

I also need to do this with a few other responses. Would I be doing this with if statements? Please let me know if I'm on the right track at all with my code. Any modifications would help me out a ton and help my understanding with python

Thank you :)

print()
print()

email = input("Enter your Email:")
name = input("Enter your Message Subject:")
name = input("Enter your Message Body:")

Problem_Saving_File = input ("Dear " + email + ", Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac). Thank you, Company Customer Service")

I_Lost_My_License = input (" Dear " + email + ", Thank you for contacting our company. You will be contacted via email to verify your license request. Thank you, Company Customer Service")
Reply
#2
Any help or recommendations would be really appreciated
Reply
#3
(Oct-08-2019, 11:11 PM)altoon Wrote: Basically what I need to happen is when I input "I Lost My License", or "Problem Saving File" into the subject of the email.

I need it to output:

Dear [email protected],
Thank you for contacting our company. You will be contacted via email
to verify your license request.
Thank you,
Company Customer Service

Hi!

Maybe you could use something like:

# license_01.py
#
 
email1 = input('Please, enter your email:\n')
subject1 = input('Please, enter your Message Subject:\n')
subject1 = subject1.lower()
messageBody1 = input('Please, enter your Message Body:\n')

if subject1 == 'i lost my license':
    print(f'''\nDear customer {email1},

Thank you for contacting our company. You will be contacted via email to verify your license request.

Thank you,

Company Customer Service''')
if subject1 == 'problem saving file':
    print(f'''\nDear customer {email1},

Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac).

Thank you,

Company Customer Service''')
if subject1 != 'i lost my license' and subject1 != 'problem saving file':
    print(f'Sorry, you should write, word for word, either "I lost my license" or "Problem saving file" on the message subject.')
that produces the following inputs and outputs:
Output:
Please, enter your email: [email protected] Please, enter your Message Subject: I Lost My License Please, enter your Message Body: Hello, blah blah blah ... Dear customer [email protected], Thank you for contacting our company. You will be contacted via email to verify your license request. Thank you, Company Customer Service
Output:
Please, enter your email: [email protected] Please, enter your Message Subject: Problem Saving File Please, enter your Message Body: Hello, blah blah blah ... Dear customer [email protected], Thank you for contacting our company. Saving a file is done by pressing CTRL-S (Windows) or CMD-S (Mac). Thank you, Company Customer Service
Output:
Please, enter your email: [email protected] Please, enter your Message Subject: This is a test. Please, enter your Message Body: Hello, blah blah blah ... Sorry, you should write, word for word, either "I lost my license" or "Problem saving file" on the message subject.

Nevertheless, note that on line 6:

subject1 = subject1.lower()
changes all the words in the message subject to lowercase, so it doesn't matter if the customer writes "I lost my license", "I lost My license", "I Lost My License", or other possibilities using the same exact words. The same applies to "Problem saving file". Keep in mind, though, that if the customer doesn't write those exact words, even if it is the United Kingdom's spelling 'licence' instead of the United States' spelling 'license', the program would take it as an invalid entered string in the message subject.

You could, of course, do the necessary changes to take this into consideration, or to apply it to your other possible message subjects.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#4
In order to save repeated typing one can use dictionaries and try...except:

email = 'somebody@somewhere'                                                           
subject = 'I lost my license'                                                          
header = (f'Dear customer {email},\n\n' 
           'Thank you for contacting our company.') 
footer = 'Thank you\n\nCompany customer service'
categories = {'i lost my license': 'You will be contacted via email to verify you license request.\n\n',
              'problem saving file': 'Saving file is done by pressing CTRL-S (Windows} or CMD- (Mac).\n\n'}

try: 
    print(f'{header}{categories[subject.lower()]}{footer}') 
except KeyError: 
    print('Sorry, dada-dada-blah-blah') 
This way one needs to add only key-value pair to categories dictionary for additional subject.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Eliminate entering QR - Whatsapp web automated by selenium akanowhere 1 3,070 Jan-21-2024, 01:12 PM
Last Post: owalahtole
  Question about Creating an Automated Process in Python Supratik1234 0 741 Jan-13-2023, 08:29 PM
Last Post: Supratik1234
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,604 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  How to get response data from telegram API call in python KanseiDorifto 0 2,593 Oct-22-2020, 12:23 PM
Last Post: KanseiDorifto
  Creating symbolic matrix automated NMMST 2 2,089 Oct-05-2020, 01:42 AM
Last Post: scidam
  Automated service status for windows Pkhan 2 2,136 Sep-30-2020, 10:30 AM
Last Post: Pkhan
  Python Requests package: Handling xml response soumyarani 1 2,152 Sep-14-2020, 11:41 AM
Last Post: buran
  Python: Automated Script to Read Multiple Files in Respective Matrices Robotguy 7 4,173 Jul-03-2020, 01:34 AM
Last Post: bowlofred
  Automated compile - Multiple Target OS? nogi 5 2,589 Mar-24-2020, 11:44 AM
Last Post: jefsummers
  Automated Bet placement redmercury 2 8,317 Dec-04-2019, 10:53 AM
Last Post: redmercury

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020