Skip to content

Commit dec49fb

Browse files
jlystgitbook-bot
authored andcommitted
GitBook: [#75] No subject
1 parent 70679ad commit dec49fb

File tree

10 files changed

+36
-38
lines changed

10 files changed

+36
-38
lines changed
46.4 KB
Loading
156 KB
Loading
223 KB
Loading

docs/.gitbook/assets/vidComing.png

108 KB
Loading

docs/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
* [Using Topics](code-mods/adding-topics.md)
2121
* [Create Flipcards](code-mods/create-flipcards.md)
2222
* [Rivescript Reference](https://www.rivescript.com/docs/tutorial)
23-
23+
* [Chatbot Project Guidebook](https://docs.idew.org/project-chatbot/)

docs/code-mods/connecting-a-database-using-google-sheets.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ You can use a Google Sheet as a database for your chatbot. Making a database thi
66

77
Below is an example of a spreadsheet of _machine learning_ terms. Of course, you could have many more terms. **The key is to make it a simple table with single word headings on the first row.**
88

9-
![Example Spreadsheet for Chatbot Database](../.gitbook/assets/dbspreadsheetex.png)
9+
![Example Spreadsheet for Chatbot Database](../.gitbook/assets/dbSpreadsheetEx.png)
1010

11-
## 2. Publish Your Google Sheet <a id="using-google-sheet-as-database-recommended"></a>
11+
## 2. Publish Your Google Sheet <a href="#using-google-sheet-as-database-recommended" id="using-google-sheet-as-database-recommended"></a>
1212

1313
In order to import your information, you will need to publish your Google Sheet.
1414

1515
1. Publish your copy of the spreadsheet by selecting `File > Publish to the web...` and click the `Publish` button.
16-
2. Once your spreadsheet is published, click the _share_ button \(upper right-hand side\) of the spreadsheet page and **copy the shareable link**. \(Make sure your link is set to _Anyone with the link can view_.\)
16+
2. Once your spreadsheet is published, click the _share_ button (upper right-hand side) of the spreadsheet page and **copy the shareable link**. (Make sure your link is set to _Anyone with the link can view_.)
1717

1818
## 3. Load the Spreadsheet Data into Your Chatbot JavaScript
1919

@@ -30,15 +30,15 @@ function setup() {
3030
}
3131
```
3232

33-
**You will need to change the `key` value \(the long number in the example above\) to the link you copied in the previous step for your Google sheet.** Your spreadsheet data is now available in an array, `chatbot.db`, where each array element represents a row in your spreadsheet as an object.
33+
**You will need to change the `key` value (the long number in the example above) to the link you copied in the previous step for your Google sheet.** Your spreadsheet data is now available in an array, `chatbot.db`, where each array element represents a row in your spreadsheet as an object.
3434

3535
{% hint style="warning" %}
36-
**For those that may have previously used `loadDB( )`:**
36+
**For those that may have previously used `loadDB( )`:**&#x20;
3737

3838
The `loadDB( )` function still works but it is being deprecated. You should use the `getDB( )` shown above since it supports loading multiple databases.
3939
{% endhint %}
4040

41-
The `chatbot.db` array now contains your spreadsheet data as a list of Javascript objects like the one shown below. See the connection to the spreadsheet we started with? So, in Javascript you could use `chatbot.db[0].keywords` to get the first term's key words \("labeled, training"\).
41+
The `chatbot.db` array now contains your spreadsheet data as a list of Javascript objects like the one shown below. See the connection to the spreadsheet we started with? So, in Javascript you could use `chatbot.db[0].keywords` to get the first term's key words ("labeled, training").
4242

4343
```javascript
4444
[
@@ -73,11 +73,11 @@ The `chatbot.db` array now contains your spreadsheet data as a list of Javascrip
7373
]
7474
```
7575

76-
## 4. Accessing the Database in a Function
76+
## 4. Accessing the Database in a Function&#x20;
7777

78-
You could now access your database in a function like the one below. This function gets a random term to quiz the chatbot user. Notice how the chatbot responds to "quiz me" by calling the `getRandomTerm` function \(object\) which returns a random term so the chatbot responds with something like "What is Reinforcement Learning?".
78+
You could now access your database in a function like the one below. This function gets a random term to quiz the chatbot user. Notice how the chatbot responds to "quiz me" by calling the `getRandomTerm` function (object) which returns a random term so the chatbot responds with something like "What is Reinforcement Learning?".
7979

80-
```text
80+
```
8181
> object getRandomTerm javascript
8282
var randomIndex = Math.floor(Math.random() * chatbot.db.length);
8383
var currentItem = chatbot.db[randomIndex]
@@ -115,4 +115,3 @@ chatbot.getDB('link', 'My First Sheet Name').then(data => chatbot.db = data);
115115
chatbot.getDB('link2', 'My Second Sheet Name').then(data => chatbot.db2 = data);
116116
chatbot.getDB('link3', 'My Third Sheet Name').then(data => chatbot.db3 = data);
117117
```
118-

docs/code-mods/searching-a-database.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Searching a Database
22

3-
Below is an example of how a chatbot could search a database of definitions and display the results as buttons for the user to click to then get the definition of that term.
4-
53
{% hint style="info" %}
64
This example uses the same database described in the example for [Connecting a Database Using Google Sheets](https://docs.idew.org/code-chatbot/code-mods/connecting-a-database-using-google-sheets), which has column names _id, term, definition, and keywords_. Your database will likely have different column names.
75
{% endhint %}
86

9-
![](../.gitbook/assets/searchexample.png)
7+
![](../.gitbook/assets/searchExample.png)
108

119
## 1. Create the Rivescript Trigger
1210

@@ -35,10 +33,10 @@ The function below will process the search and return HTML about the results.
3533

3634
Let's step through what is happening above...
3735

38-
**Line 2** uses the `chatbot.dbFilter()` function. Notice there are 3 arguments used by the function.
39-
- `chatbot.db` is the database to be searched.
40-
- `"term"` is the column name to be searched. In this case we will search each term name.
41-
- `args` represents the text the user has typed in for the search.
36+
**Line 2** uses the `chatbot.dbFilter()` function. Notice there are 3 arguments used by the function.\
37+
&#x20; \- `chatbot.db` is the database to be searched.\
38+
&#x20; \- `"term"` is the column name to be searched. In this case we will search each term name.\
39+
&#x20; \- `args` represents the text the user has typed in for the search.\
4240
The variable `filtered` now contains the matches of our search.
4341

4442
**Lines 3-5** takes each matched item and creates HTML for the term and definition that will be displayed to the user.
@@ -47,7 +45,5 @@ The variable `filtered` now contains the matches of our search.
4745

4846
**Line 7** modifies our reply with the HTML of terms and definitions if there were any matches.
4947

50-
**Line 8** uses the chatbot.postReply\(\) function to display the reply after 2 seconds.
51-
52-
48+
**Line 8** uses the chatbot.postReply() function to display the reply after 2 seconds.
5349

docs/code-mods/use-buttons-for-user-input.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Add Buttons for User Input
22

3-
![](../.gitbook/assets/buttonscreenshot.png)
3+
![](../.gitbook/assets/buttonScreenShot.png)
44

5-
While a text interface is great for allowing people to engage with natural language, there are times when a simple button has advantages allowing you to interact with specificity and save time for the user.
5+
While a text interface is great for allowing people to engage with natural language, there are times when a simple button has advantages allowing you to interact with specificity and save time for the user.&#x20;
66

77
### Use HTML Buttons Directly in the Rivescript
88

9-
Below is an example of how you could insert buttons in the chatbot's response. It uses a standard HTML button element with an `onclick` attribute to run the \`getReply\(\) function of the chatbot library. Notice how each argument in the `getReply` functions \('hello', 'bye', or 'youre awesome'\) is a string that will match a trigger in your Rivescript file.
9+
Below is an example of how you could insert buttons in the chatbot's response. It uses a standard HTML button element with an `onclick` attribute to run the \`getReply() function of the chatbot library. Notice how each argument in the `getReply` functions ('hello', 'bye', or 'youre awesome') is a string that will match a trigger in your Rivescript file.
1010

1111
{% hint style="info" %}
12-
Notice that the example below uses the continuation syntax \(`^`\) in the chatbot response to make the Rivescript easier to read. Also notice that the optional `<br>` element is used to create a line break in the chatbot interface.
12+
Notice that the example below uses the continuation syntax (`^`) in the chatbot response to make the Rivescript easier to read. Also notice that the optional `<br>` element is used to create a line break in the chatbot interface.
1313
{% endhint %}
1414

1515
{% code title="Rivescript" %}
@@ -32,4 +32,3 @@ Notice that the example below uses the continuation syntax \(`^`\) in the chatbo
3232
{% endcode %}
3333
3434
That's it. Modify as needed.
35-

docs/core-template.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
{% embed url="https://www.loom.com/share/11223bfc18be4730a9378a33f55edfbb" %}
44

5-
The code below will get you started with the iDEW chatbot template. It is a minimum starting point for a working chatbot that you will later modify and refine towards your design goals. There is a ****[**live example**](https://chatbot2018--jimlyst.repl.co/) which doesn't do anything exciting -- that's up to you to change.
5+
The code below will get you started with the iDEW chatbot template. It is a minimum starting point for a working chatbot that you will later modify and refine towards your design goals. There is a **** [**live example**](https://chatbot2018--jimlyst.repl.co) which doesn't do anything exciting -- that's up to you to change.
66

77
## HTML
88

9-
Below is the core html for the chatbot. The _div_ element with an _id="dialogue"_ is the block that contains the back-and-forth messages like you see in common messaging interfaces. The _form_ element handles the user's text input at the bottom of the interface.
9+
Below is the core html for the chatbot. The _div_ element with an _id="dialogue"_ is the block that contains the back-and-forth messages like you see in common messaging interfaces. The _form_ element handles the user's text input at the bottom of the interface.&#x20;
1010

11-
The required libraries are also loaded. _Tabletop.js_ enables you to use a back-end database using Google Sheets. _JQuery_ is a common library for Javascript programmers. _Rivescript_ is the chatbot scripting language you will use \(more on this later\). _Chatbot.js_ is the iDEW library that makes your programming easier.
11+
The required libraries are also loaded. _Tabletop.js_ enables you to use a back-end database using Google Sheets. _JQuery_ is a common library for Javascript programmers. _Rivescript_ is the chatbot scripting language you will use (more on this later). _Chatbot.js_ is the iDEW library that makes your programming easier.
1212

13-
{% code title="HTML - \(index.html\)" %}
13+
{% code title="HTML - (index.html)" %}
1414
```markup
1515
<!DOCTYPE html>
1616
<html>
@@ -47,7 +47,7 @@ The required libraries are also loaded. _Tabletop.js_ enables you to use a back-
4747

4848
Below is the minimal Javascript needed to get started. The `setup ()`function starts automatically once the page loads in the browser and simply loads the _Rivescript_ file as your chatbot script to get things started.
4949

50-
{% code title="JS \(script.js\)" %}
50+
{% code title="JS (script.js)" %}
5151
```javascript
5252
function setup() {
5353
chatbot.loadFiles(['bot.rive']);
@@ -61,7 +61,7 @@ window.onload = setup;
6161

6262
The script below determines how your chatbot will converse with a visitor. The `+ start` is automatically started to get the conversation going. The `+ *` is a wildcard that catches anything that you have not programmed your chatbot to recognize. At first your chatbot recognizes little, but we will work on that soon.
6363

64-
{% code title="Rivescript \(bot.rive\)" %}
64+
{% code title="Rivescript (bot.rive)" %}
6565
```javascript
6666
// conversation script is below
6767
// "start" auto-runs to begin the bot conversation
@@ -78,7 +78,7 @@ The script below determines how your chatbot will converse with a visitor. The `
7878
7979
There is a lot going on here with the styling of the chatbot. Use the code below as your starting point, but you may choose to change some elements later. A simple way to customize the look would be to change the _background_, _font-family_, and _color_ of the body element.
8080
81-
{% code title="CSS \(style.css\)" %}
81+
{% code title="CSS (style.css)" %}
8282
```css
8383
body {
8484
background: linear-gradient(#A90329, #6d0019);
@@ -188,4 +188,3 @@ div#dialogue {
188188
}
189189
```
190190
{% endcode %}
191-

docs/warm-up-project-outline/3-get-familiar-with-rivescript.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@
44

55
Develop a chatbot script that demonstrates several useful features and patterns in programming a conversation.
66

7+
{% hint style="warning" %}
8+
Any direct links to headings within the Rivescript documentation no longer work. Therefore, you will want to do a search for a keyword in the browser to find the content. We will update this page if we find a better way to link directly to the desired location in the Rivescript documentation.
9+
{% endhint %}
10+
11+
{% embed url="https://www.loom.com/share/eb305934b4e34d41ab5dbb450345707f" %}
12+
713
## Instructions
814

915
Let's get familiar with the syntax of RiveScript and how it will provide the logic of your chatbot. For each item below carefully look at the documentation for RiveScript to understand the options available to you as you determine what is possible with your chatbot.
1016

1117
1. **Read first section of** [**The Code, Explained**](https://www.rivescript.com/docs/tutorial#the-code-explained) **in the Rivescript documentation.** Pay close attention to the "Important Note" in the reading that describes the importance of using lowercase with triggers.
1218
2. **Create four** [**random replies**](https://www.rivescript.com/docs/tutorial#random-replies) **to "hello" for your chatbot.**
13-
3. **Define a single trigger \(a trigger is the user input that starts with a "+" in the script\) that will respond to these two user questions** - "What do you do?" or "What can you do?" with a bot answer that you choose. For example, you could respond to the user with "I do very little at the moment." Hint: use the ["alternatives and optionals" in RiveScript](https://www.rivescript.com/docs/tutorial#alternatives-and-optionals).
19+
3. **Define a single trigger (a trigger is the user input that starts with a "+" in the script) that will respond to these two user questions** - "What do you do?" or "What can you do?" with a bot answer that you choose. For example, you could respond to the user with "I do very little at the moment." Hint: use the ["alternatives and optionals" in RiveScript](https://www.rivescript.com/docs/tutorial#alternatives-and-optionals).
1420
4. Use [a redirection](https://www.rivescript.com/docs/tutorial#redirections) to your "hello" trigger when the user inputs "Hey". Basically, make your bot respond the same way to _hello_ or _hey._
15-
5. **Create a reply to "My name is Sue" \(or any name\).** In your chatbot response, use the person's name---like, "Nice to meet you Sue, my name is ChattyBot." Hint: Use an [open-ended trigger with a wildcard](https://www.rivescript.com/docs/tutorial#open-ended-triggers).
16-
6. **Have your bot kick-off the conversation with** _**a question**_ **when it starts so the visitor knows how to continue the conversation.** Also, add the needed script to listen for a response to that question and respond. Take a look at [this example on short discussions](https://www.rivescript.com/docs/tutorial#short-discussions).
21+
5. **Create a reply to "My name is Sue" (or any name).** In your chatbot response, use the person's name---like, "Nice to meet you Sue, my name is ChattyBot." Hint: Use an [open-ended trigger with a wildcard](https://www.rivescript.com/docs/tutorial#open-ended-triggers).
22+
6. **Have your bot kick-off the conversation with **_**a question**_** when it starts so the visitor knows how to continue the conversation.** Also, add the needed script to listen for a response to that question and respond. Take a look at [this example on short discussions](https://www.rivescript.com/docs/tutorial#short-discussions).
1723
7. **Finally, choose two other features of RiveScript syntax to implement in your bot.**
1824

1925
## ✓ Deliverable
2026

2127
Have your chatbot working with the features described above and be prepared to demonstrate and explain how it works.
22-

0 commit comments

Comments
 (0)