Post Google Forms Responses into Kintone
Overview
This article introduces how to post Google Forms responses into Kintone Apps using Google Apps Script.
Benefits of the Integration
Google Forms allows end users to easily create and send questionnaires and event invitations. 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 Forms questions can be made private. The permissions can be set so that only the HR department can view the submitted data. - Business Process Management
Workflows can be set for each record in the Kintone App. This makes the actions after the form submission much 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. They can reach out to a Sales team member who may have some connection with the submitter of the form.
Prepare Google Forms
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 and 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.
Prepare a Kintone App
Create an App
Log in to Kintone, and create an App with the following fields and settings.
Field Type | Field Name | Field Code |
---|---|---|
Link (Type: URL) | ||
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 |
The form should look like the following:
Generate an API Token
Generate an API Token by following the steps in the Generating API Tokens article in the Kintone help site. Apply the Add records permissions to the API Token. Save the settings, and apply the changes to the App.
Prepare a Google Apps Script Program
Step 1
Reopen the Google Form, open the menu on the top right, and select Script editor.
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 Script ID from the link above.
Paste the Script ID into the Add a Library field. Click Add to add the library, select the latest version, and save the settings.
Step 3
Type the following code in to the Google Apps Script editor.
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. Match the values of subdomain
, appid
, and token
to values that correspond to the Kintone App.
Make sure to also change the subdomain, appid, and token to values that correspond to the Kintone App.
|
|
Save the code when done.
Step 4
Select Triggers from the Edit menu and select a function to run when an event occurs of the Google Form. Click Save when done.
Step 5
In the Project Settings, check the check box for the Show 'appsscript.json' manifest file in editor option.
Return to the editor, and add the below OAuth scopes in appsscript.json.
|
|
Test the integration
Click the Send button in the upper right corner of the created Google form. Fill out the options to send the form to other users.
Recipients will receive links to the Google Form.
Once the form is submitted, the response data should be added to Kintone App.
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.
|
|