簡體   English   中英

亞馬遜 Alexa 閱讀谷歌電子表格

[英]Amazon Alexa reading Google Spreadsheets

我對自定義 Amazon Alexa Reading Google Sheet 很感興趣。 我嘗試創建代碼來啟用一些 Alexa 功能,例如閱讀、編輯和列表,但我無法正確完成和運行輸出。

我有單獨的工作塊中的代碼。 我嘗試使用 Alexa Node JS 和 Google Node JS。 您認為有可能將它們組合在一起並使其發揮作用嗎? 我想尋求幫助,因為我已經堅持了幾個月了。

對於 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');
    }
};

對於谷歌,我按照以下鏈接獲取分步指南https://developers.google.com/sheets/api/quickstart/nodejs

謝謝藍瑟

您可以通過兩種方式訪問 Google 電子表格中的內容:

  • 使用public電子表格:如果您將工作表設置為公開,則只需使用電子表格 ID 和您嘗試訪問的工作表的位置,即可通過 JSON 端點訪問內容: https://spreadsheets.google.com/feeds/list/${spreadsheetId}/${sheetPosition}/public/values?alt=json ://spreadsheets.google.com https://spreadsheets.google.com/feeds/list/${spreadsheetId}/${sheetPosition}/public/values?alt=json
  • 使用private電子表格:這有點復雜,因為您需要進行身份驗證並使用Google Sheets API

用於 Alexa Skills 和 Google Actions 的 Jovo Framework 提供了一個Google Spreadsheets CMS 集成,可以為您完成所有不必要的工作。 它提供不同的工作表類型,因此您可以按照自己喜歡的方式訪問內容,而無需自己進行解析。 您可以在此處找到分步教程和視頻:教程:使用 Google 表格作為語音應用程序的 CMS

我也在尋找 Alexa to Google 表格,到目前為止,我剛剛發現了用於 google docs 的這項技能,它可能有助於為您提供一些線索。

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

要使用身份驗證訪問私人 Google 電子表格,您可以使用 NodeJS 庫google-spreadsheet

一旦連接和身份驗證成功,就可以非常簡單地訪問電子表格數據以進行讀取或寫入。

讀訪問示例:

// 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');

文檔在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM