You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-13Lines changed: 29 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ Code samples related to [Building Better Bots](https://aws.amazon.com/blogs/ai/b
3
3
4
4
# CoffeeBot
5
5
6
-
CoffeeBot is a transactional chat bot that can help one order a mocha (relies on AWS Mobile Hub and Android).
6
+
CoffeeBot is a transactional chat bot that can help one order a coffee.
7
7
8
8
Consider this conversation:
9
9
> User: May I have a mocha?
@@ -26,18 +26,17 @@ Consider this conversation:
26
26
27
27
> CoffeeBot: Great! Your mocha will be available for pickup soon. Thanks for using CoffeeBot!
28
28
29
-
Let's build this voice bot, an Android App that talks to you using Amazon Polly and Amazon Lex.
30
-
You'll need the following in addition to your AWS account:
31
-
- Android development environment ([download](https://developer.android.com/sdk))
32
-
- To test voice (you can use the simulator for text)
33
-
- An Android device
34
-
- A USB cable for USB debugging ([more info for Amazon Fire tablets](https://developer.amazon.com/public/solutions/devices/fire-tablets/app-development/setting-up-your-development-environment-for-fire-tablets))
35
29
36
-
37
-
First, we'll create the Amazon Lex bot. Then, we'll add some Lambda Functions to bring it to life. Finally, we'll put it all together with Mobile Hub and the Lex Android SDK.
30
+
First, we'll create the Amazon Lex bot. Then, we'll add some Lambda Functions to bring it to life. Lastly, as an optional step, create an Android application with the Mobile Hub and the Lex Android SDK.
38
31
39
32
## Amazon Lex bot
33
+
Amazon Lex is a service for building conversational interfaces into any application using voice and text.
34
+
35
+
We will be creating a custom bot in the console and applying the necessary intents and custom slots in order to understand the coffee order.
36
+
40
37
#### 1. Create bot
38
+
First, we'll create the bot.
39
+
41
40
1. From the Amazon Lex console, create a Custom bot with these settings (you can see these in the "Settings" tab later)
42
41
- Bot name: `CoffeeBot`
43
42
- To work independently in a shared environment, use your initials in the name (e.g., `CoffeeBotXXX`)
@@ -49,9 +48,9 @@ First, we'll create the Amazon Lex bot. Then, we'll add some Lambda Functions t
49
48
50
49

51
50
52
-
- Prompts: (one prompt) `Sorry, but I didn't understand that. Would you try again, please?`
53
-
- Maximum number of retries: `2`
54
-
- Hang-up phrase: (one phrase) `Sorry, I could not understand. Goodbye.`
51
+
- Prompts: (one prompt) `Sorry, but I didn't understand that. Would you try again, please?`
52
+
- Maximum number of retries: `2`
53
+
- Hang-up phrase: (one phrase) `Sorry, I could not understand. Goodbye.`
55
54
56
55
#### 2. Create Order Beverage Intent
57
56
@@ -89,6 +88,8 @@ Slot type name | Description | Values (each entry on a separate line)
89
88
`cafeBeverageTemp` | | `kids`; `hot`; `iced`
90
89
91
90
#### 4. Add Slots to the Intent
91
+
From the intent page of your cafeOrderBeverageIntent, locate "Slots" midway down the page.
92
+
92
93
Add the following entries to the list of Slots, choosing the Slot Types created above. Click "Save Intent".
93
94
94
95
Required | Name | Slot type | Prompt
@@ -99,9 +100,16 @@ Required | Name | Slot type | Prompt
99
100
| `BeverageTemp` | `cafeBeverageTemp` | `Would you like that iced or hot?`
100
101
101
102
#### 5. Test
102
-
Build the app and test some of the Utterances in the Test Bot dialog at the bottom right of the Amazon Lex Console. For example, if you say `May I have a chai?`, does Lex correctly map `chai` to the `BeverageType` slot?
103
+
104
+

105
+
106
+
Click the build icon in the upper right hand corner to build the app. This can take a few minutes.
107
+
108
+
Once built, a new panel will appear on the right of the Amazon Lex Console where you can test some of the Utterances in the Test Bot dialog. For example, if you say `May I have a chai?`, does Lex correctly map `chai` to the `BeverageType` slot?
103
109
104
110
## Lambda Function
111
+
Now that we've tested that our application works, let's add more logic to validate our choices and handle the processing of the order.
112
+
105
113
1. Create the `cafeOrderCoffee` function by saving `cafeOrderCoffee_lambda.js` as a Node.js 6.10 function
106
114
- To work independently in a shared environment, use your initials in the function name (e.g., `cafeOrderCoffeeXXX`)
107
115
- You can get the function source [here](https://github.com/awslabs/amz-ai-building-better-bots/blob/master/src/index.js)
@@ -125,6 +133,14 @@ Build the app and test some of the Utterances in the Test Bot dialog at the bott
125
133
1. Test using the Amazon Lex Console; do you see any responses when you ask `May I have a mocha?`
126
134
127
135
## Android App
136
+
Now, let's build this voice bot through an Android App that talks to you using Amazon Polly and Amazon Lex.
137
+
You'll need the following in addition to your AWS account:
138
+
- Android development environment ([download](https://developer.android.com/sdk))
139
+
- To test voice (you can use the simulator for text)
140
+
- An Android device
141
+
- A USB cable for USB debugging ([more info for Amazon Fire tablets](https://developer.amazon.com/public/solutions/devices/fire-tablets/app-development/setting-up-your-development-environment-for-fire-tablets))
142
+
143
+
128
144
1. From the Mobile Hub console, create a new project called `CoffeeBot`.
129
145
1. Add the "Conversational Bots" feature to the project. When prompted, import `CoffeeBot`. Mobile Hub takes care of a number of important details behind the scenes. A new Amazon Cognito Federated Identity Pool is created for this new app along with roles so that the users can interact with Lex (using voice and text).
130
146
1. Source code for the new app is immediately available for download.
0 commit comments