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: docs/code-mods/connecting-a-database-using-google-sheets.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,14 +84,29 @@ You could now access your database in a function like the one below. This functi
84
84
85
85
Wow. That's seems like a lot of work for such a short dialogue. But now you could have one of 10,000 terms randomly displayed to the user. There will be more examples of functions accessing a database in the listed _Code Mods_.
86
86
87
-
## 5. Adding more databases
87
+
## 5. Using multiple databases
88
88
89
-
You may want to use multiple databases in your chatbot. You can reuse the `getDB( )` function to load several databases like below, allowing you to access each database with `chatbot.db`, `chatbot.db2`, and `chatbot.db3`.
89
+
#### Separate Google Sheets Files
90
+
91
+
If you want to access multiple Google Sheet files to create multiple databases, you can reuse the `getDB( )` function to load several databases like below. This allows you to access each database with `chatbot.db`, `chatbot.db2`, and `chatbot.db3`.
90
92
91
93
```javascript
92
-
//replace the 'link' text in each to match your spreadsheet link
94
+
// replace the 'link' text in each to match your spreadsheet links
If you want to use a single Google Sheets File that has multiple named sheets, you can use the `getDB( )` function in the following way. Notice that you must include the _sheet name_ along with the _link_ in this case.
104
+
105
+
```javascript
106
+
// replace the 'link' text and 'sheet name' in each to match your spreadsheet link
107
+
// and corresponding sheet names
108
+
chatbot.getDB('link', 'My First Sheet Name').then(data=>chatbot.db= data);
109
+
chatbot.getDB('link2', 'My Second Sheet Name').then(data=>chatbot.db2= data);
110
+
chatbot.getDB('link3', 'My Third Sheet Name').then(data=>chatbot.db3= data);
0 commit comments