3

I got interested in customizing the Amazon Alexa reading Google Sheet. I tried to create codes to enable some of the Alexa functions such as read, edit and list but I was not able to complete and run the output properly.

I have the code in separate working chunks. I tried to use the Alexa Node JS and Google Node JS. Do you think it is possible to combine them together and get it working? I would like to ask for help since I am stuck for in this for months already.

For the Alexa:

'use strict';

var Alexa = require("alexa-sdk");

exports.handler = function(event, context, callback) {
    var alexa = Alexa.handler(event, context);
    alexa.registerHandlers(handlers);
    alexa.execute();
};

var handlers = {
    'ReadFileIntent': function () {
        console.log ('In Read File Request')
        this.emit(':tell', 'Read');
    },
    'LaunchRequest': function () {
        console.log ('In Launch Request')
        this.emit(':tell', 'SayHello');
    }
};

For the Google, I followed the below link for a step by step guide https://developers.google.com/sheets/api/quickstart/nodejs

starball
  • 20,030
  • 7
  • 43
  • 238
Kiralancer
  • 51
  • 1
  • 7
  • Can you provide more of your code (Maybe a github link)? And exactly where you are stuck? Error trace will help. – AkshayM Jul 26 '18 at 12:47

3 Answers3

3

There are two options how you can access content from a Google Spreadsheet:

  • Using a public spreadsheet: If you set your sheet to public, you can access the content through a JSON endpoint by just using the spreadsheet ID and the position of the sheet you're trying to access: https://spreadsheets.google.com/feeds/list/${spreadsheetId}/${sheetPosition}/public/values?alt=json
  • Using a private spreadsheet: This is a little more complicated, as you need to do authentication and use the Google Sheets API

The Jovo Framework for Alexa Skills and Google Actions offers a Google Spreadsheets CMS integration that does all the unnecessary work for you. It offers different sheet types so you can access content in the way you prefer and don't need to do the parsing yourself. You can find a step-by-step tutorial and video here: Tutorial: Use Google Sheets as CMS for your Voice App.

Jan König
  • 440
  • 3
  • 12
0

I am also looking for Alexa to Google sheets, so far I've just found this skill for google docs, it might help give you some clues.

https://github.com/acucciniello/alexa-open-doc

macasas
  • 497
  • 6
  • 20
0

To access a private Google Spreadsheets with authentication you can use the NodeJS library google-spreadsheet.

It ist quite simple to access spreadsheet data either for reading or writing once the connection and authentication have succeeded.

Example for read access:

// Auth first...
const { GoogleSpreadsheet } = require('google-spreadsheet');
// spreadsheet key is the long id in the sheets URL
const doc = new GoogleSpreadsheet('<the sheet ID from the url>');
// use API key -- only for read-only access to public sheets
doc.useApiKey('YOUR-API-KEY');

// ... then read your cells
const c6 = sheet.getCellByA1('C6');

The docs are here.

WeSee
  • 3,158
  • 2
  • 30
  • 58