Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alifeee/8ee6ffdbeafec1e3b58e202aea5182be to your computer and use it in GitHub Desktop.
Save alifeee/8ee6ffdbeafec1e3b58e202aea5182be to your computer and use it in GitHub Desktop.
Create a new GitHub Issue from a Google Form submission

Wiring up a Google Form to GitHub is not that difficult with a little bit of Apps Script automation. All you need is a Google account, a GitHub account, and a web browser...

Set up your GitHub Personal Access Token

Personal access tokens provide an easy way to interact with the GitHub API without having to mess with OAuth. If you don't already have a personal access token with repo or public_repo access, visit your GitHub settings page and generate a new token.

Be sure to copy your token some place safe and keep it secure. Once generated, you will not be able to view or copy the token again.

Set up the Form & Spreadsheet

  1. Create a Google Form.
  2. From the Responses tab, click the More icon.
  3. Select Choose a response destination.
  4. Select New spreadsheet: Creates a new spreadsheet in Google Sheets for responses.
  5. Click Create to create and open the sheet.

Configure the App Script Logic

  1. You should have a newly created blank spreadsheet with headers automatically generated from your form.
  2. Click Tools > Script editor... to launch the App Script editor coding environment. This Script will be bound to your form, so you can listen for form submissions and fire off a new issue to your GitHub repo.
  3. Add a script property under Settings named "github-token" and containing your GitHub access token
  4. Delete the boilerplate code in the file and replace it with something similar to this:
let props = PropertiesService.getScriptProperties().getProperties();
let ghToken = props["github-token"];
let ghlink = ""

function onFormSubmit(e) {

  let itemResponses = e.response.getItemResponses();
  let titles = => response.getItem().getTitle())
  let items = => response.getResponse())

  Logger.log("response items: %s", items)

  let title = items[0];

  let body = "";
  for (var i = 0; i < itemResponses.length; i++) {
    body += "### " + titles[i] + "\n\n";
    body += items[i] + "\n\n";
  let payload = {
    "title": title,
    "body": body
  let options = {
    "method": "POST",
    "headers": {
      "authorization": "token "+ghToken,
      "Accept": "application/vnd.github.v3+json",
    "contentType": "application/json",
    "payload": JSON.stringify(payload)

  Logger.log("Payload: %s", payload)
  var response = UrlFetchApp.fetch(ghlink + ghToken, options);
  1. The onFormSubmit function includes an event object e, which includes the form responses with titles and items as simple arrays with values in the same order as they appear in the spreadsheet. items[0] is the first spreadsheet column after timestamp.
  2. Reference the GitHub Issues API for a full list of options for programmatically creating a new issue.
  3. Once we've built the title and body of the issue, we can build the HTTP request using App Script's URL Fetch Service.
  4. Give your app script project a name and save it.

Set up the Trigger

  1. From within the app script editor, click Resources > Current project's triggers.
  2. Click to add a trigger
    • Run: onFormSubmit
    • Events: From spreadsheet, On form submit
  3. Click Save and accept any authorizations to access your forms and access web services on your behalf.
  4. This trigger will listen to form submissions and pass the data to your function, which POSTs the new issue to your GitHub repo.


This exercise demonstrates how to utilize Google Forms as a front-end for capturing information, which can then be passed on to other services, such as GitHub, CartoDB, Fulcrum, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment