Introduction
This article introduces how to capture Google Form responses into Kintone using Google Apps Script.
Google Forms allows end users to easily create and send questionnaires and event invitations, but there are many advantages of capturing the form responses into Kintone's databases over spreadsheets.
- Access controls
Kintone allows end users to set granular access controls to the data in its Apps. For example, records that have a "Keep private" answer for one of their Google Form questions can be set so that only the HR department will be able to view the submission data. - Business Process Management
Workflows can be set for each record in the Kintone App, which makes the post form submission actions clearer. For example, after receiving a Google Forms submission into Kintone, the record can be assigned to a Design team member to work on creating creatives related to the submission data. - Communication
Each record inside the Kintone App has a feature for posting comments for other team members to read. For example, after receiving a Google Forms submission, an Events team member can write a comment in the record, to reach out to a Sales team member who may have some connection with the submitter of the form.
This tutorial goes through the following steps for development:
- Create a Google Form
- Create a Kintone App
- Create a Google Apps Script program
Step 1. Create a Google Form
Step 1
A Google account will be needed for this step.
Log in to the Google account and select Google Forms from the Google app icon (or directly login from https://docs.google.com/forms/), and click the [+] under Start a new form.
Step 2
Enter a title and description for the form.
Step 3
Click the Settings icon, check Collect email address, uncheck all boxes under Requires sign in, and save the changes.
Step 4
Click the Add Question icon and select a question type such as Multiple choice. Enter a question in the question field, as well as the response options.
Select Required as below if the question is mandatory.
Step 5
Repeat the process and add more questions.
Google Forms will automatically save every change that is made.
2. Create a Kintone App
Step 1
Log in to Kintone, and create a new Kintone App with fields similar to the ones placed in the Google Form.
For reference, this is the Kintone App layout and settings used in the screenshots in this tutorial.
Field Type |
Field Name |
Field Code |
---|---|---|
Link |
|
|
Radio Button |
Would you like to participate in this event? |
attend |
Number |
The number of participants |
number_of_participants |
Text Area |
The names of the participants |
names_of_participants |
Step 2
Click on the Apps settings tab, and click on API Token.
Generate a new API Token, check the Add records check-box, and save the settings.
Apply the changes made to your App by clicking Update App.
3. Create a Google Apps Script Program
Step 1
Reopen the Google form created in the previous step and click Script editor from the Other menu.
Enter a project name and a file name.
Step 2
The following library is used in this tutorial: https://github.com/Arahabica/KintoneManager
Copy the Project Key from the link above. In Google Forms, select Resources and then Libraries.
Paste the project key into the Add a Library field. Click Add to add the library, select the latest version, and save the settings.
Step 3
Copy the following code in to the Google Apps Script.
The strings Email, attend, number_of_participants, and names_of_participants that are listed in the code are the field codes of the fields in the Kintone App. Make sure these names match the field code in the App.
Make sure to also change the subdomain, appid, and token to values that correspond to the Kintone App.
Once finished, save the code.
Code Explanation
Getting data from the Google form
The e.response.getItemResponses() function retrieves the submitted form data:
The e.reponse.getRespondentEmail() function is used to get the email address of the form submitter, and the request data for Kintone is created:
Sending data to Kintone
The information of the Kintone App created above is set with the following:
The imported library is initialized, the request data is JSON formatted, and is then sent to Kintone:
The submission to Kintone succeeds if the response code is 200.
Step 4
Select Current project’s triggers from the Edit menu and select a function to run when an event occurs of the Google Form. Click Save when done.
The set up for Google Apps Script is now complete.
4. Test the integration
Click the Send button in the upper right corner of the created Google form, fill out the Send form, and click the Send button.
Recipients will receive links to the Google Form.
Once the form is submitted, the response data should be added to your Kintone App.
Finally
Using Google form enables the user to easily create forms for questionnaires, event attendance, etc. and send them to recipients via email or SNS, as well as embedding them in a company website. It also lets the user manage data results efficiently by registering responses to a Kintone App automatically.