Build a Bot with Zero Coding

ItamarMItamarM RSS Feed

Most bot tutorials are for people who can code, so if you don’t have developers or staff with extra time on their hands your custom needs may not be met. Building a bot requires technical resources, such as servers to run the logic, storage to store data points and developers, well, to code. Until now. In this tutorial, we’ll show how you can build a survey bot right from a Google Sheet.


Why?

Instead of using a server to run your bot logic (which is actually easy, but it requires maintenance), use Google as your hosting environment on your behalf and use Google Sheets to keep track of the survey answers!

Animation flow

Code running on a spreadsheet?

Google Apps Script is a JavaScript-based scripting language that lets you add functionality to your Google Apps. It is a cloud‑based language that integrates with all other Google services, including Gmail, Google Drive, Calendar, Google Forms, Sheets and more. Apps Script is incredibly versatile. It allows you to:

Prerequisites

How?

1. Make a copy of the spreadsheet

https://docs.google.com/spreadsheets/d/187abmrkYlgoDZrYPChgQZiG2btfi98YPWrYYMF42UpQ/edit?usp=sharing

In Google Sheets, Click File > Make a copy

make-copy

This should give you something like this:

copy-of-sheet

Note: Feel free to change the name of the Copy to anything you want, it will not affect the outcome.

2. Under the parameters sheet, edit the following fields:

parameters-sheet

This is the difference between a keyboard with specific colors versus one generated with random colors:

parameters-sheet

3. Under the questions sheet, edit your questions:

Question types

Our survey bot supports three (3) different types of questions: range, keyboard and text:

Editing questions

Each row in the spreadsheet equals to a survey question and ordered by sequence. Hence the first row (after the header) will contain the first question, while the 7th row will contain the seventh question.

Adding a range question

Adding a keyboard question

Adding a text question

4. Open the Script Editor

Open the Script editor... by clicking “Tools” > “Script editor...

script-editor

5. Publish the script as a Web App

publish-script

Select the latest project version to deploy.

Note: You must select the Anyone, even anonymous option for the “Who has access to the app” dropdown or form responses will not be added to the spreadsheet!

deploy-new-version

6. Authorize the script to access your Google Sheet data on Google

auth-required

Copy the web app URL to your clipboard / note pad. Then Click “OK”.

deploy-as-web-app

7. Set the WebHook on Viber

Viber chat API console is a helper site set up for this integration, specifically to help you set up a WebHook. This way Viber will know to communicate with your Sheet.

Select the Set a WebHook operation, paste your web app URL from the previous step and click the Apply button to make the change.

set-web-hook-console

Done. That’s it. You just created your very own survey chat bot! Your survey answers will populate on the answers sheet.

deploy-as-web-app

Want more?

Feel free to customize the code, add more question types, improve the flow or even accept pictures as valid input!

How to report bugs

If you find any issues with this sample, please open an issue on GitHub.

Background reading

Need help or found a bug? Contact us.