星期二, 12月 01, 2026

[GAS] Forms 接受回應設定

嘗試透過 AI 使用 GAS 建立 Google Forms 時發現,原來「接受回應」功能,目前只能設定兩個
  • 是否接受回應
  • 表單關閉時文字訊息,Google Forms 畫面上是這樣描述:若表單不再接受回覆,作答者就會看到這則訊息
表單關閉的「設定截止日或回覆限制」,目前還沒有辦法透過 GAS 直接設定,只能繞道處理
  • 指定日期:建立 GAS 觸發器
  • 達到指定回覆數之後:使用 onFormSubmit 處理
我是選擇手動去 Google Forms 上設定就好,沒有一定要 GAS 處理到位,但我沒有常常製作 Google Forms 需求就是

該筆記重點放在「表單關閉時文字訊息」設定上,因為官方文件上範例-setCustomClosedFormMessage(message) 無法正常設定
// Opens the Forms file by its URL. If you created your script from within a
// Google Forms file, you can use FormApp.getActiveForm() instead.
// TODO(developer): Replace the URL with your own.
const form = FormApp.openByUrl('https://docs.google.com/forms/d/abc123456/edit',);

// Sets the form to not accept responses.
form.setAcceptingResponses(false);

// Sets a custom closed form message to display to the user.
form.setCustomClosedFormMessage('The form is no longer accepting responses.');

// Gets the custom message set for the form and logs it to the console.
const message = form.getCustomClosedFormMessage();
console.log(message);
修正後語法
const form = FormApp.openByUrl('https://docs.google.com/forms/d/1aLQnrVyq8WZkUrczW3oUt_Xg4xnjd6xLy3ALmu-sNIk/edit',);

const isAccepting = form.isAcceptingResponses();
try {
  if (!isAccepting) {
    form.setAcceptingResponses(true);
  }

  form.setCustomClosedFormMessage('The form is no longer accepting responses.');
  form.setAcceptingResponses(false);

} finally {
  form.setAcceptingResponses(isAccepting);
}

const message = form.getCustomClosedFormMessage();
console.log(message);
setCustomClosedFormMessage() 必須在 Forms 是接受回應狀態下才可以進行設定,一旦表單關閉,就無法設定表單關閉時文字訊息

星期五, 11月 20, 2026

[Line] Flex Message - 輪播卡

多張 Flex Message 卡片 (bubble) 可以設定為輪播卡 (carousel),使用者在手機 Line 上左右滑動瀏覽每張卡片,非常適合做「商品目錄」、「功能選單」或「教學章節導覽」,該筆記是「教學章節導覽」為主,把之前三篇文章摘要並整理為輪播卡

輪播卡限制
  • 最多只能包含 12 張卡片
  • 整個輪播訊息的資料大小不能超過 50KB
  • 每張卡片寬度都會是一樣的
  • 每張高度會自動保持一致,系統會以最高的卡片為基準,將所有卡片的 body 都對齊到相同高度,該卡片沒有 body 的話則不受影響
官方卡片高度說明
The body of each bubble will stretch to match the tallest bubble in the carousel. However, bubbles with no body will not change height.

code.gs
function getCarouselCard() {
  return {
    type: 'carousel',
    contents: [
      // 第 1 張卡片:對應 [Line] Flex Message - Hello World
      {
        type: 'bubble',
        size: 'kilo',
        header: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'text',
              text: 'STEP 01|2026/11/03',
              color: '#DCFCE7',
              size: 'xs',
              weight: 'bold'
            },
            {
              type: 'text',
              text: 'Hello World 基礎卡片',
              color: '#FFFFFF',
              size: 'lg',
              weight: 'bold',
              wrap: true
            }
          ]
        },
        body: {
          type: 'box',
          layout: 'vertical',
          spacing: 'sm',
          contents: [
            {
              type: 'text',
              text: '文章重點:',
              weight: 'bold',
              size: 'sm',
              color: '#1E293B'
            },
            {
              type: 'text',
              text: '• 透過 GAS 串接 Push API 主動推播\n• payload 指定 type: flex 與 altText\n• 認識 bubble 單卡與 body 基礎區塊\n• vertical 垂直容器與文字 wrap 設定',
              size: 'xs',
              color: '#475569',
              wrap: true,
              lineSpacing: '4px'
            }
          ]
        },
        footer: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'button',
              style: 'primary',
              height: 'sm',
              color: '#16A34A',
              action: {
                type: 'uri',
                label: '閱讀文章',
                uri: 'https://jengting.blogspot.com/2026/11/Hello-Flex-Message.html'
              }
            }
          ]
        },
        styles: {
          header: {
            backgroundColor: '#16A34A'
          }
        }
      },
      // 第 2 張卡片:對應 [Line] Flex Message - 排版容器應用
      {
        type: 'bubble',
        size: 'kilo',
        header: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'text',
              text: 'STEP 02|2026/11/07',
              color: '#DBEAFE',
              size: 'xs',
              weight: 'bold'
            },
            {
              type: 'text',
              text: '排版容器應用(雙欄)',
              color: '#FFFFFF',
              size: 'lg',
              weight: 'bold',
              wrap: true
            }
          ]
        },
        body: {
          type: 'box',
          layout: 'vertical',
          spacing: 'sm',
          contents: [
            {
              type: 'text',
              text: '文章重點:',
              weight: 'bold',
              size: 'sm',
              color: '#1E293B'
            },
            {
              type: 'text',
              text: '• 垂直與水平巢狀容器製作雙欄明細\n• flex 屬性控制左右欄位空間比例\n• header 標題列與 separator 分隔線\n• align 對齊技巧製作活動入場憑證',
              size: 'xs',
              color: '#475569',
              wrap: true,
              lineSpacing: '4px'
            }
          ]
        },
        footer: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'button',
              style: 'primary',
              height: 'sm',
              color: '#2563EB',
              action: {
                type: 'uri',
                label: '閱讀文章',
                uri: 'https://jengting.blogspot.com/2026/11/Flex-Message-Layout.html'
              }
            }
          ]
        },
        styles: {
          header: {
            backgroundColor: '#2563EB'
          }
        }
      },
      // 第 3 張卡片:對應 [Line] Flex Message - 圖文與按鈕
      {
        type: 'bubble',
        size: 'kilo',
        header: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'text',
              text: 'STEP 03|2026/11/14',
              color: '#FEF3C7',
              size: 'xs',
              weight: 'bold'
            },
            {
              type: 'text',
              text: '圖文與按鈕互動',
              color: '#FFFFFF',
              size: 'lg',
              weight: 'bold',
              wrap: true
            }
          ]
        },
        body: {
          type: 'box',
          layout: 'vertical',
          spacing: 'sm',
          contents: [
            {
              type: 'text',
              text: '文章重點:',
              weight: 'bold',
              size: 'sm',
              color: '#1E293B'
            },
            {
              type: 'text',
              text: '• hero 滿版主視覺與 aspectRatio 設定\n• baseline 基準線對齊星星評分圖示\n• footer 按鈕樣式(primary/secondary)\n• uri 開啟網頁與 message 關鍵字觸發',
              size: 'xs',
              color: '#475569',
              wrap: true,
              lineSpacing: '4px'
            }
          ]
        },
        footer: {
          type: 'box',
          layout: 'vertical',
          contents: [
            {
              type: 'button',
              style: 'primary',
              height: 'sm',
              color: '#D97706',
              action: {
                type: 'uri',
                label: '閱讀文章',
                uri: 'https://jengting.blogspot.com/2026/11/Flex-Message-Image.html'
              }
            }
          ]
        },
        styles: {
          header: {
            backgroundColor: '#D97706'
          }
        }
      }
    ]
  };
}

星期三, 11月 18, 2026

[Zoom] 音訊增強

透過 Zoom 分享聲音時發現,平常播的音樂透過 Zoom 分享後,整個音質下降很多且聽起來就是有種糊糊的感覺還伴隨著隨機破音,後來發現 Lenovo ThinkPad 筆電內 Windows 11 有 [音訊增強] 設定,把它關閉後過 Zoom 分享聲音就正常了

星期六, 11月 14, 2026

[Line] Flex Message - 圖文與按鈕

該筆記重點
  • hero 區塊:放置滿版主視覺圖片
  • layout-baseline:專門用來把小圖示 (icon) 與文字 (text) 沿著文字底部基準線對齊,該範例內容是應用在星級評分
  • footer 區塊 + button 控件
    • action.type-uri:點擊後直接開啟外部網頁
Flex Message json 和發出效果
function getCafeCard() {
  return {
    "type": "bubble",
    "size": "mega",
    "hero": {
      "type": "image",
      "url": "https://images.unsplash.com/photo-1501339847302-ac426a4a7cbb?auto=format&fit=crop&w=1000&q=80",
      "size": "full",
      "aspectRatio": "20:13",
      "aspectMode": "cover"
    },
    "body": {
      "type": "box",
      "layout": "vertical",
      "spacing": "sm",
      "contents": [
        {
          "type": "text",
          "text": " 圖文與按鈕",
          "weight": "bold",
          "color": "#D97706",
          "size": "xs"
        },
        {
          "type": "text",
          "text": "楓花雪岳 Kaffe",
          "weight": "bold",
          "size": "xl",
          "color": "#1E293B",
          "wrap": true
        },
        {
          "type": "box",
          "layout": "baseline",
          "margin": "md",
          "contents": [
            {
              "type": "icon",
              "size": "sm",
              "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
            },
            {
              "type": "icon",
              "size": "sm",
              "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
            },
            {
              "type": "icon",
              "size": "sm",
              "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
            },
            {
              "type": "icon",
              "size": "sm",
              "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
            },
            {
              "type": "icon",
              "size": "sm",
              "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
            },
            {
              "type": "text",
              "text": "4.9 (128 則評論)",
              "size": "sm",
              "color": "#64748B",
              "margin": "md",
              "flex": 0
            }
          ]
        },
        {
          "type": "box",
          "layout": "vertical",
          "margin": "lg",
          "spacing": "sm",
          "contents": [
            {
              "type": "box",
              "layout": "horizontal",
              "spacing": "sm",
              "contents": [
                {
                  "type": "text",
                  "text": "招牌推薦",
                  "color": "#94A3B8",
                  "size": "sm",
                  "flex": 2
                },
                {
                  "type": "text",
                  "text": "衣索比亞 紫風鈴 ($200)",
                  "wrap": true,
                  "color": "#334155",
                  "size": "sm",
                  "flex": 5
                }
              ]
            },
            {
              "type": "box",
              "layout": "horizontal",
              "spacing": "sm",
              "contents": [
                {
                  "type": "text",
                  "text": "營業時間",
                  "color": "#94A3B8",
                  "size": "sm",
                  "flex": 2
                },
                {
                  "type": "text",
                  "text": "每日10:00 營業(週一公休)",
                  "wrap": true,
                  "color": "#334155",
                  "size": "sm",
                  "flex": 5
                }
              ]
            }
          ]
        }
      ]
    },
    "footer": {
      "type": "box",
      "layout": "vertical",
      "spacing": "sm",
      "flex": 0,
      "contents": [
        {
          "type": "button",
          "style": "primary",
          "height": "sm",
          "color": "#D97706",
          "action": {
            "type": "uri",
            "label": "楓花雪岳官網",
            "uri": "https://jengting.blogspot.com/"
          }
        }
      ]
    }
  };
}
Image
  • Size:有三種設定方式,分別為尺寸關鍵字、像素、百分比,預設值為尺寸 md
  • aspectRatio:設定圖片顯示區域的寬高比,寬與高的數值範圍為 1-100,000,且高不能超過寬的 3 倍,未設定預設為 1:1
  • aspectMode:設定圖片如何填入顯示區域,當原始圖片比例與 aspectRatio 不一致時,就由這個屬性決定顯示方式
    • cover:照片放大到填滿寬度,上下部分會被裁掉
    • fit:整張照片完整顯示,左右會留下空間
layout-baseline

官方文件 示意圖,直接看圖理解囉
Button

style
  • primary:適合深色底的主要按鈕
  • secondary:適合淺色底的次要按鈕
  • link:文字連結樣式,也是預設值
action 屬性
  •  uri:開啟指定網址
  • message:點擊後讓使用者在聊天室送出指定文字,可以應用在觸發關鍵字回覆 (可觸發 Webhook 回應)

星期六, 11月 07, 2026

[Line] Flex Message - 排版容器應用

該筆記練習使用垂直、水平排版容器,來製作雙欄明細資訊

Flex Message json 和發出效果
function getMultiColumnJson() {
  return {
    "type": "bubble",
    "size": "mega",
    "header": {
      "type": "box",
      "layout": "vertical",
      "contents": [
        {
          "type": "text",
          "text": "雙欄明細資訊",
          "color": "#BFDBFE",
          "size": "xs",
          "weight": "bold"
        },
        {
          "type": "text",
          "text": "實戰工作坊入場憑證",
          "color": "#FFFFFF",
          "size": "lg",
          "weight": "bold",
          "margin": "xs"
        }
      ]
    },
    "body": {
      "type": "box",
      "layout": "vertical",
      "spacing": "md",
      "contents": [
        {
          "type": "text",
          "text": "LineBot × GAS 自動化實戰班",
          "weight": "bold",
          "size": "md",
          "color": "#0F172A",
          "wrap": true
        },
        {
          "type": "separator",
          "margin": "md",
          "color": "#E2E8F0"
        },
        {
          "type": "box",
          "layout": "vertical",
          "margin": "md",
          "spacing": "sm",
          "contents": [
            {
              "type": "box",
              "layout": "horizontal",
              "contents": [
                {
                  "type": "text",
                  "text": "活動日期",
                  "size": "sm",
                  "color": "#64748B",
                  "flex": 1
                },
                {
                  "type": "text",
                  "text": "2026/11/15 (日) 14:00",
                  "size": "sm",
                  "color": "#1E293B",
                  "weight": "bold",
                  "flex": 2,
                  "align": "end"
                }
              ]
            },
            {
              "type": "box",
              "layout": "horizontal",
              "contents": [
                {
                  "type": "text",
                  "text": "上課地點",
                  "size": "sm",
                  "color": "#64748B",
                  "flex": 1
                },
                {
                  "type": "text",
                  "text": "台北市 OO 區 XX 路 ZZ 號",
                  "size": "sm",
                  "color": "#1E293B",
                  "flex": 2,
                  "align": "end",
                  "wrap": true
                }
              ]
            },
            {
              "type": "box",
              "layout": "horizontal",
              "contents": [
                {
                  "type": "text",
                  "text": "報到序號",
                  "size": "sm",
                  "color": "#64748B",
                  "flex": 1
                },
                {
                  "type": "text",
                  "text": "#GAS-888",
                  "size": "sm",
                  "color": "#2563EB",
                  "weight": "bold",
                  "flex": 2,
                  "align": "end"
                }
              ]
            }
          ]
        },
        {
          "type": "separator",
          "margin": "md",
          "color": "#E2E8F0"
        },
        {
          "type": "text",
          "text": "排版技巧:利用垂直排版容器搭配水平排版容器,即可做出對齊資訊欄位",
          "size": "xs",
          "color": "#94A3B8",
          "wrap": true,
          "margin": "md"
        }
      ]
    },
    "styles": {
      "header": {
        "backgroundColor": "#7C3AED"
      }
    }
  }
}

巢狀容器

在垂直排版容器 (下圖綠色框) 內放入多個水平排版容器 (下圖黃色框),水平排版容器內放置文字標籤,藉此來顯示雙欄位文字資訊

屬性 flex

flex 則是決定水平排版容器內的文字標籤佔整個水平空間比例,以該例子來說,左側文字標籤設定 flex: 1 、右側文字標籤設定 flex: 2,所以水平空間總比例為 3 ,左側文字標籤代表佔 1/3、右側文字標籤代表佔 2/3