質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
LINE Messaging API

LINE Messaging APIは、メッセージの送信・返信ができるAPIです。Web APIを経由しアプリケーションサーバとLINEのAPIでやり取りが可能。複数のメッセージタイプや分かりやすいAPIリファレンスを持ち、グループチャットにも対応しています。

Dialogflow

Dialogflowは、Googleが提供している自然言語対話プラットフォーム。音声入力で自然言語の解析を行ってくれる機能で、対話型アプリを簡単に作成することが可能です。

Google Apps Script

Google Apps ScriptはGoogleの製品と第三者のサービスでタスクを自動化するためのJavaScriptのクラウドのスクリプト言語です。

Q&A

解決済

1回答

3829閲覧

Google Apps Scriptでsheet.appendRowができない。

ytommy

総合スコア11

LINE Messaging API

LINE Messaging APIは、メッセージの送信・返信ができるAPIです。Web APIを経由しアプリケーションサーバとLINEのAPIでやり取りが可能。複数のメッセージタイプや分かりやすいAPIリファレンスを持ち、グループチャットにも対応しています。

Dialogflow

Dialogflowは、Googleが提供している自然言語対話プラットフォーム。音声入力で自然言語の解析を行ってくれる機能で、対話型アプリを簡単に作成することが可能です。

Google Apps Script

Google Apps ScriptはGoogleの製品と第三者のサービスでタスクを自動化するためのJavaScriptのクラウドのスクリプト言語です。

0グッド

1クリップ

投稿2020/06/14 10:11

編集2020/06/14 20:39

前提・実現したいこと

LINE messaging API、Google apps script、Dialogflowを利用して予約管理システムを開発しています。
GASでsheet.appendRowができません。
下記のパラメータのdateとanyはスプレッドシートに表示されるのですが、それ以外が表示されません。

該当のソースコード

#Google apps script function doGet(e) { var sheet = SpreadsheetApp.openById('xxx').getSheetByName('xxx'); var result = {}; if (e.parameter == undefined) { //受信に失敗した場合 result['result']= 'NG'; } else { //受信に成功した場合 var num = 1 var date = new Date(); var currentTime = Utilities.formatDate( date, 'Asia/Tokyo', 'yyyyMMdd: hhmmss') var date = e.parameter['date']; var name = e.parameter['any']; sheet.appendRow([num, currentTime, name,date]); result['result']= 'OK'; num++ } return ContentService.createTextOutput(JSON.stringify(result)); }
#Dialogflow fulfillment // See https://github.com/dialogflow/dialogflow-fulfillment-nodejs // for Dialogflow fulfillment library docs, samples, and to report issues 'use strict'; const functions = require('firebase-functions'); const {WebhookClient} = require('dialogflow-fulfillment'); const {Card, Suggestion} = require('dialogflow-fulfillment'); //httpsの利用を宣言する const https = require('https'); process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => { const agent = new WebhookClient({ request, response }); console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers)); console.log('Dialogflow Request body: ' + JSON.stringify(request.body)); function namae(agent) { return new Promise((resolve, reject) => { let context = agent.getContext('hinichi-followup'); let date = context['parameters']['date']; let name = agent.parameters['any']; let url = 'xxx; //httpのリクエストを送信 let req = https.get(url, (res) => { let chunk = ''; //読み込み中の処理 res.on('data', (c) => { chunk += c; }); //読み込み完了時の処理 res.on('end', () => { //処理終了 resolve(); }); }); //エラー時の処理 req.on('error', (e) => { console.error(`エラー: ${e.message}`); }); }); } function welcome(agent) { agent.add(`Welcome to my agent!`); } function fallback(agent) { agent.add(`I didn't understand`); agent.add(`I'm sorry, can you try again?`); } // // Uncomment and edit to make your own intent handler // // uncomment `intentMap.set('your intent name here', yourFunctionHandler);` // // below to get this function to be run when a Dialogflow intent is matched // function yourFunctionHandler(agent) { // agent.add(`This message is from Dialogflow's Cloud Functions for Firebase editor!`); // agent.add(new Card({ // title: `Title: this is a card title`, // imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png', // text: `This is the body text of a card. You can even use line\n breaks and emoji! ????`, // buttonText: 'This is a button', // buttonUrl: 'https://assistant.google.com/' // }) // ); // agent.add(new Suggestion(`Quick Reply`)); // agent.add(new Suggestion(`Suggestion`)); // agent.setContext({ name: 'weather', lifespan: 2, parameters: { city: 'Rome' }}); // } // // Uncomment and edit to make your own Google Assistant intent handler // // uncomment `intentMap.set('your intent name here', googleAssistantHandler);` // // below to get this function to be run when a Dialogflow intent is matched // function googleAssistantHandler(agent) { // let conv = agent.conv(); // Get Actions on Google library conv instance // conv.ask('Hello from the Actions on Google client library!') // Use Actions on Google library // agent.add(conv); // Add Actions on Google library responses to your agent's response // } // // See https://github.com/dialogflow/fulfillment-actions-library-nodejs // // for a complete Dialogflow fulfillment library Actions on Google client library v2 integration sample // Run the proper function handler based on the matched Dialogflow intent name let intentMap = new Map(); intentMap.set('namae', namae); intentMap.set('Default Welcome Intent', welcome); intentMap.set('Default Fallback Intent', fallback); // intentMap.set('your intent name here', yourFunctionHandler); // intentMap.set('your intent name here', googleAssistantHandler); agent.handleRequest(intentMap); });

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

draq

2020/06/14 13:32

スプレッドシートのIDやWEBアプリとして公開したURLをソースコード中にベタ書きして公開するのはやめた方がいいでしょう。 質問は編集できるので消した方がいいです。
ytommy

2020/06/14 21:36

修正しました。 ありがとうございました。
macaron_xxx

2020/06/18 22:55

>dateとanyはスプレッドシートに表示される 3,4列目に表示されますか?
ytommy

2020/06/20 01:04

>>dateとanyはスプレッドシートに表示される >3,4列目に表示されますか? 1列目、2列目に表示されます。
macaron_xxx

2020/06/23 06:54

Webアプリとして公開する時に新しい版を作成していないのではないですか?
ytommy

2020/06/26 23:53

おっしゃる通りで、バージョンをNewにしたところ解決いたしました。 ありがとうございました。
guest

回答1

0

自己解決

バージョンをNewにしたところ解決いたしました。

投稿2020/06/26 23:56

ytommy

総合スコア11

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問