前提・実現したいこと
プログラミングほぼ初心者です。
gasを使ってslack上でのアンケートを実装予定です。アンケートの結果をスプレッドシートに反映させることを目指しています。
###ここに質問の内容を詳しく書いてください。
gasを扱うことが初めてなので、まずはサンプルコードを使ってSlackAPIを動かしてみました。
下記のコードを元に、選択した際に下記2点を実装したいです。
・スプレッドシートに{名前}{value値}を反映させるようにする。
・選択に対してユーザーにコメントを返す(例:あなたはaとbを選びました)
dopost関数を使うことはわかりますがどのように書いていいかわかりません。ご教授お願いします。
発生している問題・エラーメッセージ
該当のソースコード
javascript
1function sendMsgWithButton() { 2 3 4 var slackUrl = ["URL"]; 5 6 7 var messageData = { 8 "text": "アンケート", 9 "attachments": [ 10 { 11 "text": "~選んでください", 12 "fallback": "Sorry, no support for buttons.", 13 "callback_id": "ButtonResponse", 14 "color": "#3AA3E3", 15 "attachment_type": "default", 16 "actions": [ 17 { 18 "name": "button", 19 "text": "非常に満足", 20 "style": "primary", 21 "type": "button", 22 "value": "1" 23 }, 24 { 25 "name": "button", 26 "text": "少し満足", 27 "style": "primary", 28 "type": "button", 29 "value": "2" 30 }, 31 { 32 "name": "button", 33 "text": "普通", 34 "style": "primary", 35 "type": "button", 36 "value": "3" 37 }, 38 { 39 "name": "button", 40 "text": "あまり満足でない", 41 "style": "primary", 42 "type": "button", 43 "value": "4" 44 }, 45 { 46 "name": "button", 47 "text": "非常に満足していない", 48 "style": "primary", 49 "type": "button", 50 "value": "5" 51 }, 52 ] 53 }, 54 { 55 "text":"~選んでください", 56 "callback_id": "ptNotificationButtonResponse2", 57 "color":"warning", 58 "actions":[ 59 { 60 "name": "select", 61 "text": "Select test", 62 "style": "primary", 63 "type": "select", 64 "options": [ 65 { 66 text:"あ", 67 value:"a" 68 }, 69 { 70 text:"い", 71 value:"b" 72 }, 73 { 74 text:"う", 75 value:"c" 76 } 77 ] 78 } 79 ] 80 }, 81 ] 82 } 83 84 var options = { 85 'method' : 'post', 86 'contentType': 'application/json', 87 88 'payload' : JSON.stringify(messageData) 89 }; 90 91 92 UrlFetchApp.fetch(slackUrl, options); 93 }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。