571 lines
27 KiB
Plaintext
571 lines
27 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Off-Platform Project 1: Customer Service Bot\n",
|
||
|
"\n",
|
||
|
"Hi there! In this off-platform project, you will be working as a software engineer for the **Definitely Not Sinister Cable Company**! They have hired you to build for them a bot that can handle basic customer service requests on their website.\n",
|
||
|
"\n",
|
||
|
"First, you will learn a little bit about handling user input, then we will jump right in and start building the functions you need to generate an interactive customer serivce bot.\n",
|
||
|
"\n",
|
||
|
"Let's get started!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Input( )\n",
|
||
|
"\n",
|
||
|
"In Python 3, you can handle basic user text input by using the built-in function `input()`. This is how we will have users interact with your customer service bot. You use `input()` by defining a variable and setting it equal to `input(\"text the user is responding to\")`. \n",
|
||
|
"\n",
|
||
|
"Run the following two code blocks to see how `input()` works."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"name = input(\"What is your name? \")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"print(name)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Your response to the question \"What is your name?\" was stored in the variable `name`, which was then printed in the next cell. Great, that's all you need to know for now! Let's get started building the customer service bot!\n",
|
||
|
"\n",
|
||
|
"## Step 1\n",
|
||
|
"\n",
|
||
|
"Before going any further, Go to the 'Cell' drop down at the menu at the top of this notebook and select 'Run All'. This will run all of the cells below so that everything we need to build the customer service bot is ready.\n",
|
||
|
"\n",
|
||
|
"## Step 2\n",
|
||
|
"\n",
|
||
|
"Great, let's get started. First in the cell below, define the function `cs_service_bot`. This will be our main function. Every time a user accesses our support, this function will be called and will guide them through a decision tree to identify their support needs and find them a solution.\n",
|
||
|
"\n",
|
||
|
"1. This function should start by printing:\n",
|
||
|
" Hello! Welcome to the DNS Cable Company's Service Portal. Are you a new or existing customer?\n",
|
||
|
" [1] New Customer\n",
|
||
|
" [2] Existing Customer\n",
|
||
|
" You can store this all in a single string and use the escape character `\\n` to indicate line breaks.\n",
|
||
|
"\n",
|
||
|
"2. Next we want to ask them to choose an option. We are going to do that using `input()`. Make a variable called `response` and have it save the users response using `input()`. You should include text to let the user know how they should make their choice, such as:\n",
|
||
|
" Please enter the number corresponding to your choice: \n",
|
||
|
"3. If the user selects `1` the function should direct them to another function `new_customer()`. We will define this function later.\n",
|
||
|
"4. If the user selects `2` the function should direct them to another function `existing_customer()`. We will define this function later as well.\n",
|
||
|
"5. Finally, if the user enters something other than a `1` or `2` we want our function to print \n",
|
||
|
" Sorry, we didn't understand your selection.\n",
|
||
|
" and then run `cs_serivce_bot` again to let them make another choice."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def cs_service_bot():\n",
|
||
|
" print(\"Hello! Welcome to the DNS Cable Company's Service Portal. Are you a new or existing customer? \\n [1] New Customer \\n [2] Existing Customer\")\n",
|
||
|
" response_one = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response_one == \"1\":\n",
|
||
|
" new_customer()\n",
|
||
|
" elif response_one == \"2\":\n",
|
||
|
" existing_customer()\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" cs_service_bot()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Great Job! Run `cs_service_bot()` in the cell below and see how it works."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"Cool! We have the initial skeleton done, now we have to define `new_customer()` and `existing_customer()`.By breaking up our bot into a bunch of smaller functions we can build each piece incrementally and check our progress as we slowly build a fully functioning product.\n",
|
||
|
"\n",
|
||
|
"## Step 3\n",
|
||
|
"Let's start with `existing_customer()`. The options **DNS Cable Company** wants users to be able to select are \n",
|
||
|
"\n",
|
||
|
" [1] Television Support\n",
|
||
|
" [2] Internet Support\n",
|
||
|
" [3] Speak to a support representative. \n",
|
||
|
"\n",
|
||
|
"Have `existing_customer()` print \"What kind of support do you need?\" and then these three options. Remember, use the escape character `\\n` in strings for line breaks. Use `input()` in the same way as the previous function to record the users choice.\n",
|
||
|
"\n",
|
||
|
"1. If they select `1`, call the function `television_support()` which will we define later.\n",
|
||
|
"2. If they select `2`, call the function `internet_support()` which we will also define later.\n",
|
||
|
"3. If they select `3`, call the function `live_rep()` with the argument `\"support\"`. We'll use this argument to indicate what type of live representative the user will talk to. We will define the function later.\n",
|
||
|
"4. Finally, just like the `cs_service_bot()` function, if the user enters something other than the three options above, have the function print\n",
|
||
|
" Sorry, we didn't understand your selection.\n",
|
||
|
"and call itself to let them try again."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def existing_customer():\n",
|
||
|
" print(\"What kind of support do you need? \\n [1] Television Support \\n [2] Internet Support \\n [3] Speak to a support representative\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" television_support()\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" internet_support()\n",
|
||
|
" elif response == \"3\":\n",
|
||
|
" live_rep(\"support\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" existing_customer()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 4\n",
|
||
|
"You can see that we've introduced a whole new slew of functions as options of `existing_customer()`, and we'll define those soon but first let's define `new_customer()`.\n",
|
||
|
"\n",
|
||
|
"The options the **DNS Cable Company** wants for `new_customer()` are \n",
|
||
|
" \n",
|
||
|
" [1] Sign up for service.\n",
|
||
|
" [2] Schedule a home visit.\n",
|
||
|
" [3] Speak to a sales representative.\n",
|
||
|
" \n",
|
||
|
"They also want this function to greet their potential new customers with the phrase \"We're excited to have you join the DNS family, how can we help you?\" A little cheesy if you ask me but hey, the client is always right.\n",
|
||
|
"\n",
|
||
|
"1. If the user selects `1`, call the function `sign_up()`.\n",
|
||
|
"2. If the user selects `2`, call the function `home_visit()`.\n",
|
||
|
"3. If the user selects `3`, call the function `live_rep()` with the argument `\"sales\"` so the program directs them to the correct live representative.\n",
|
||
|
"4. Finally, like the other functions, if the user sumbits something other than the options above, display an error message and call the function again."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def new_customer():\n",
|
||
|
" print(\"We're excited to have you join the DNS family, how can we help you? [1] Sign up for service. \\n [2] Schedule a home visit. \\n [3] Speak to a sales representative.\")\n",
|
||
|
" response_two = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response_two == \"1\":\n",
|
||
|
" sign_up()\n",
|
||
|
" elif response_two == \"2\":\n",
|
||
|
" home_visit()\n",
|
||
|
" elif response_two == \"3\":\n",
|
||
|
" live_rep(\"sales\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" new_customer()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 5\n",
|
||
|
"\n",
|
||
|
"Now it's time to dive down another level and start defining the next level of functions. Let's start with `television_support()`. **DNS Cable Company** has compiled the three most frequently reported issues and wants those to be surfaced as options in the bot as follows after the prompt \"What is the nature of your problem?\":\n",
|
||
|
"\n",
|
||
|
" [1] I can't access certain channels.\n",
|
||
|
" [2] My picture is blurry.\n",
|
||
|
" [3] I keep losing service.\n",
|
||
|
" \n",
|
||
|
"They also want a fourth catch-all option\n",
|
||
|
"\n",
|
||
|
" [4] Other issues.\n",
|
||
|
" \n",
|
||
|
"Now, for each of these options, they want to give the user the most useful advice they have.\n",
|
||
|
"\n",
|
||
|
"1. If the user enters `1` they want to print the following message and then call the function `did_that_help()` which we will define next. \n",
|
||
|
" Please check the channel lists at DefinitelyNotSinister.com. If the channel you cannot access is there, please contact a live representative.\n",
|
||
|
"2. If the user enters `2` they want to print the following message and then call the function `did_that_help()`\n",
|
||
|
" Try adjusting the antenna above your television set.\n",
|
||
|
"3. If the user enters `3` they want to print the following message and then call the function `did that help()`\n",
|
||
|
" Is it raining outside? If so, wait until it is not raining and then try again.\n",
|
||
|
"4. If the user enters `4` it should direct them immediately to `live_rep(\"support\")`\n",
|
||
|
"5. Just like the other functions, if the user enters something other than these options it should present an error message and call the function again."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def television_support():\n",
|
||
|
" print(\"What is the nature of your problem? \\n [1] I can't access certain channels. \\n [2] My picture is blurry. \\n [3] I keep losing service. \\n [4] Other issue.\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" print(\"Please check the channel lists at DefinitelyNotSinister.com. If the channel you cannot access is there, please contact a live representative.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" print(\"Try adjusting the antenna above your television set.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"3\":\n",
|
||
|
" print(\"Is it raining outside? If so, wait until it is not raining and then try again.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"4\":\n",
|
||
|
" live_rep(\"support\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" television_support()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 6\n",
|
||
|
"\n",
|
||
|
"Next, we will define `internet_support()`, which is will be extremely similar to the function you just defined, `television_support()` except with different possible support issues. Here are the issues that **DNS Cable Company** wants included:\n",
|
||
|
"\n",
|
||
|
" [1] I can't connect to the internet.\n",
|
||
|
" [2] My connection is very slow.\n",
|
||
|
" [3] I can't access certain sites.\n",
|
||
|
" \n",
|
||
|
"Just like for television support, they also want a fourth option for `Other Issues`.\n",
|
||
|
"\n",
|
||
|
"They've highlighted these suggested fixes for each of the issues:\n",
|
||
|
"\n",
|
||
|
"1. If the user selects `1`, the function should recommend the following solution and then call `did_that_help()`.\n",
|
||
|
" Unplug your router, then plug it back in, then give it a good whack, like the Fonz.\n",
|
||
|
"2. If the user selects `2`, the function should recommend the following solution and then call `did_that_help()`.\n",
|
||
|
" Make sure that all cell phones and other peoples computers are not connected to the internet, so that you can have all the bandwidth.\n",
|
||
|
"3. If the user selects `3`, the function should recommend the following solution and then call `did_that_help()`.\n",
|
||
|
" Move to a different region or install a VPN. Some areas block certain sites.\n",
|
||
|
"4. If the user selects `4`, the function should call `live_rep(\"support\")`\n",
|
||
|
"5. Finally, if the user enters something other than the options above, print an error message and recall the function."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def internet_support():\n",
|
||
|
" print(\"What is the nature of your problem? \\n [1] I can't connect to the internet. \\n [2] My connection is very slow. \\n [3] I can't access certain sites. \\n [4] Other issue.\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" print(\"Unplug your router, then plug it back in, then give it a good whack, like the Fonz.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" print(\"Make sure that all cell phones and other peoples computers are not connected to the internet, so that you can have all the bandwidth.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"3\":\n",
|
||
|
" print(\"Move to a different region or install a VPN. Some areas block certain sites.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" elif response == \"4\":\n",
|
||
|
" live_rep(\"support\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" internet_support()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 7\n",
|
||
|
"\n",
|
||
|
"Great work! The last two functioned called the function `did_that_help()`, which we will define now. The purpose of `did_that_help()` is to check if the user was helped by the solution to their problem, and if not, ask them if they'd rather speak to a live representative over the phone or schedule a home visit.\n",
|
||
|
"\n",
|
||
|
"The structure of the function should be as followed:\n",
|
||
|
"1. Ask the user if the solution solved their problem and have them answer Yes or No using `input()`.\n",
|
||
|
"2. If yes, thank them.\n",
|
||
|
"3. If no, prompt them with another question and ask them if they would rather talk to a live representative or schedule a home visit.\n",
|
||
|
"4. If they want to talk to a representative, call `live_rep(\"support\")`\n",
|
||
|
"5. If they want to schedule a home visit, call `home_visit(\"support\")`\n",
|
||
|
"6. Make sure to include error messages for both user responses if they enter a choice not listed above"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def did_that_help():\n",
|
||
|
" print(\"Did that solve the problem? \\n [1] Yes \\n [2] No\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" print(\"Great! Have a wonderful day.\")\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" print(\"We're sorry. Would you like to talk to a live representative or schedule a home visit to address your problem? \\n [1] Live Representative [2] Home Visit\")\n",
|
||
|
" response_two = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response_two == \"1\":\n",
|
||
|
" live_rep(\"support\")\n",
|
||
|
" elif response_two == \"2\":\n",
|
||
|
" home_visit(\"support\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" did_that_help()\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" did_that_help()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 8\n",
|
||
|
"Now we've defined all of the initial options of `existing_customer()`, so we'll move onto the options for `new_customer()`, first let's define `sign_up()`.\n",
|
||
|
"\n",
|
||
|
"**DNS Cable Company** is very specific about the greeting they want new customers to see:\n",
|
||
|
"\n",
|
||
|
" Great choice, friend! We're excited to have you join the DNS family! Please select the package you are interested in signing up for.\n",
|
||
|
" [1] Bundle Deal (Internet + Cable)\n",
|
||
|
" [2] Internet\n",
|
||
|
" [3] Cable\n",
|
||
|
" \n",
|
||
|
"Apparently, they want their users to be forced to sign up if they reach this stage! Here's what they want each option to do:\n",
|
||
|
"\n",
|
||
|
"1. If a user selects `1`, they want to print the following message and then call `home_visit(\"new install\")`\n",
|
||
|
" You've selected the Bundle Package! Please schedule a home visit and our technician will come and set up your new service.\n",
|
||
|
"2. If a user selects `2`, they want to print the following message and then call `home_visit(\"new install\")`\n",
|
||
|
" You've selected the Internet Only Package! Please schedule a home visit and our technician will come and set up your new service.\n",
|
||
|
"3. If a user selects `3`, they want to print the following message and then call `home_visit(\"new install\")`\n",
|
||
|
" You've selected the Cable Only Package! Please schedule a home visit and our technician will come and set up your new service.\n",
|
||
|
"4. If a user enters something other than the above choices, print an error message and call `sign_up()` again."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def sign_up():\n",
|
||
|
" print(\"Great choice, friend! We're excited to have you join the DNS family! Please select the package you are interested in signing up for. \\n [1] Bundle Deal (Internet + Cable) \\n [2] Internet \\n [3] Cable\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" print(\"You've selected the Bundle Package! Please schedule a home visit and our technician will come and set up your new service.\")\n",
|
||
|
" home_visit(\"new install\")\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" print(\"You've selected the Internet Only Package! Please schedule a home visit and our technician will come and set up your new service.\")\n",
|
||
|
" home_visit(\"new install\")\n",
|
||
|
" elif response == \"3\":\n",
|
||
|
" print(\"You've selected the Cable Only Package! Please schedule a home visit and our technician will come and set up your new service.\")\n",
|
||
|
" home_visit(\"new install\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" sign_up() "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"## Step 9\n",
|
||
|
"Now we've got an interesting function to define, `home_visit()`. We've called `home_visit()` in three different ways in other functions. In `new_customer()` we call `home_visit()` with no argument, in `internet_support()` and `television_support()` we call `home_visit(\"support\")`, and in `sign_up()` we call `home_visit(\"new install\")`.\n",
|
||
|
"\n",
|
||
|
"This means we want `home_visit()` to take a parameter, which we can call `purpose`, but we want this parameter to be optional with a default value of `\"none\"`.\n",
|
||
|
"\n",
|
||
|
"Now, `home_visit()` should first check `purpose` and then do one of the following:\n",
|
||
|
"1. If `purpose == \"none\"`, we need to determine the purpose of the home visit, so ask the user what the purpose of the home visit is and give them the options\n",
|
||
|
" [1] New service installation.\n",
|
||
|
" [2] Exisitng service repair.\n",
|
||
|
" [3] Location scouting for unserviced region.\n",
|
||
|
" 1. If they select `1` here, call `home_visit(\"new install\")`\n",
|
||
|
" 2. If they select `2` here, call `home_visit(\"support\")`\n",
|
||
|
" 3. If they select `3` here, call `home_visit(\"scout\")`\n",
|
||
|
"\n",
|
||
|
"For all other options, first ask the user\n",
|
||
|
" \n",
|
||
|
" Please enter a date below when you are available for a technician to come to your home and [PURPOSE SPECIFC TEXT HERE].\n",
|
||
|
"\n",
|
||
|
"and save their response to the variable `visit_date`, then respond \n",
|
||
|
" \n",
|
||
|
" Wonderful! A technical will come visit you on [visit_date]. Please be available between the hours of 1:00 am and 11:00 pm.\n",
|
||
|
" \n",
|
||
|
"and return `visit_date`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def home_visit(purpose=\"none\"):\n",
|
||
|
" if purpose == \"none\":\n",
|
||
|
" print(\"What is the purpose of your home visit? \\n [1] New service installation. \\n [2] Existing service repair. \\n [3] Location scouting for unserviced regions.\")\n",
|
||
|
" response = input(\"Please enter the number corresponding to your choice: \")\n",
|
||
|
" if response == \"1\":\n",
|
||
|
" home_visit(\"new install\")\n",
|
||
|
" elif response == \"2\":\n",
|
||
|
" home_visit(\"support\")\n",
|
||
|
" elif response == \"3\":\n",
|
||
|
" home_visit(\"scout\")\n",
|
||
|
" else:\n",
|
||
|
" print(\"Sorry, we didn't understand your selection.\")\n",
|
||
|
" home_visit()\n",
|
||
|
" if purpose == \"new install\":\n",
|
||
|
" print(\"Please enter a date below when you are available for a technician to come to your home and install your new service.\")\n",
|
||
|
" visit_date = input(\"Date:\")\n",
|
||
|
" print(\"Wonderful! A technical will come visit you on \" + visit_date + \". Please be available between the hours of 1:00 am and 11:00 pm.\" )\n",
|
||
|
" return visit_date\n",
|
||
|
" if purpose == \"support\":\n",
|
||
|
" print(\"Please enter a date below when you are available for a technician to come and inspect the problem:\")\n",
|
||
|
" visit_date = input(\"Date:\")\n",
|
||
|
" print(\"Wonderful! A technical will come visit you on \" + visit_date + \". Please be available between the hours of 1:00 am and 11:00 pm.\" )\n",
|
||
|
" return visit_date\n",
|
||
|
" if purpose == \"scout\":\n",
|
||
|
" print(\"Please enter a date below when you are available for a technician to come scout your region for expansion:\")\n",
|
||
|
" visit_date = input(\"Date:\")\n",
|
||
|
" print(\"Wonderful! A technical will come visit you on \" + visit_date + \". Please be available between the hours of 1:00 am and 11:00 pm.\" )\n",
|
||
|
" return visit_date"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"## Step 10\n",
|
||
|
"Great work! We have one last function to define! `live_rep()` is called by several different functions, but it always called with one of two arguments, `\"sales\"` or `\"support\"`. All this function needs to do is print a message to the user based on the argument.\n",
|
||
|
"\n",
|
||
|
"1. If the function is called with an argument of `\"sales\"`, print \n",
|
||
|
" Please hold while we connect you with a live sales representative. The wait time will be between two minutes and six hours. We thank you for your patience.\n",
|
||
|
"2. If the function is called with an argument of `\"support\"`, print \n",
|
||
|
" Please hold while we connect you with a live sales representative. The wait time will be between two minutes and six hours. We thank you for your patience."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def live_rep(purpose):\n",
|
||
|
" if purpose == \"sales\":\n",
|
||
|
" print(\"Please hold while we connect you with a live sales representative. The wait time will be between two minutes and six hours. We thank you for your patience.\")\n",
|
||
|
" if purpose == \"support\":\n",
|
||
|
" print(\"Please hold while we connect you with a live sales representative. The wait time will be between two minutes and six hours. We thank you for your patience.\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Step 11\n",
|
||
|
"\n",
|
||
|
"That's it, your customer service bot should be up and running! Test your code and run `cs_service_bot` and go through some of the choices! Make sure all of your options work and you end up where you expect after each decision."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"cs_service_bot()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## You're Done!\n",
|
||
|
"\n",
|
||
|
"Great work! Using very simple functions and conditional stables you were able to build a working customer service bot! While it might be a little limited in it's current state, you can always keep adding to it, making each individual function more robust. Some suggestions, try adding in a option to each menu that allows the user to exit without clicking through the entire tree.\n",
|
||
|
"\n",
|
||
|
"You can even build other types of projects using similar techniques! Try building a chat bot that can respond to what you say and ask you questions, or create a text based adventure game where players can make choices to do different actions.\n",
|
||
|
"\n",
|
||
|
"The possibilities are endless! So keep going and happy programming!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.6.5"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|