สร้างเงื่อนไขเริ่มต้นและขั้นตอนการดำเนินการของ Workspace Studio ที่กำหนดเอง

1. บทนำ

ใน Codelab นี้ คุณจะได้สร้าง Support Quick Portal แบบอินเทอร์แอกทีฟที่เชื่อมต่อกับ Google Workspace Studio โดยตรง คุณจะได้เรียนรู้วิธีสร้างทั้งขั้นตอนเริ่มต้นที่กำหนดเองและขั้นตอนการดำเนินการที่กำหนดเองซึ่งทดสอบได้ทันทีโดยไม่ต้องอาศัยโครงสร้างพื้นฐานของบุคคลที่สาม

เราจะใช้ Google Apps Script เพื่อสร้างสิ่งต่อไปนี้

  • เว็บแอปที่มีแบบฟอร์มที่สวยงามเพื่อให้ผู้ใช้ส่งคำขอรับการสนับสนุนด้วยตนเอง
  • Custom Starter ที่บันทึกการส่งเว็บแอปเหล่านั้นและทริกเกอร์โฟลว์ Workspace Studio
  • ขั้นตอนที่กำหนดเองซึ่งจะวิเคราะห์คำอธิบายของคำขอที่เข้ามาเพื่อระบุระดับความเร่งด่วน ("สูง" หรือ "ปกติ")

สิ่งที่คุณจะได้เรียนรู้

  • วิธีกำหนดค่าสตาร์ทเตอร์และขั้นตอนในไฟล์ Manifest ของ appsscript.json
  • วิธีสร้าง notifyUri ในช่วงวงจรการลงทะเบียนเริ่มต้น
  • วิธีทริกเกอร์โฟลว์ Workspace Studio จากโค้ดภายนอกโดยใช้ UrlFetchApp โดยอัตโนมัติ
  • วิธีกำหนดตัวแปรเอาต์พุตในขั้นตอนที่กำหนดเองเพื่อส่งต่อข้อมูลไปยังขั้นตอนถัดไป

ข้อกำหนดเบื้องต้น

  • บัญชี Google Workspace ที่เปิดใช้ Google Workspace Studio
  • การตั้งค่าอนุญาตขั้นตอนที่กำหนดเองที่ยังไม่ได้เผยแพร่ (ทดสอบ) ที่เปิดใช้ในคอนโซลผู้ดูแลระบบของโดเมน (ในส่วนแอป > Google Workspace > Workspace Studio > การตั้งค่าขั้นตอนที่กำหนดเอง)
  • คุ้นเคยกับ Google Apps Script

2. ตั้งค่าโปรเจ็กต์ Apps Script

ก่อนอื่น ให้สร้างโปรเจ็กต์ Apps Script ใหม่เพื่อเก็บโค้ดของเรา

  1. ไปที่ script.google.com แล้วคลิกโปรเจ็กต์ใหม่
  2. ตั้งชื่อโปรเจ็กต์ว่า Support Quick Portal
  3. คลิกการตั้งค่าโปรเจ็กต์ การตั้งค่าโปรเจ็กต์ในแถบด้านข้างซ้าย
  4. ทำเครื่องหมายในช่องเพื่อแสดงไฟล์ Manifest appsscript.json ในเอดิเตอร์
  5. กลับไปที่มุมมองผู้แก้ไข เอดิเตอร์

โดยค่าเริ่มต้น โปรเจ็กต์ Apps Script จะเชื่อมโยงกับโปรเจ็กต์ที่อยู่ในระบบคลาวด์เริ่มต้นที่ซ่อนอยู่ของ Google Cloud หากต้องการเรียก Google Workspace Studio API และหลีกเลี่ยงข้อผิดพลาด PERMISSION_DENIED คุณต้องเปลี่ยนสคริปต์เป็นโปรเจ็กต์ที่อยู่ในระบบคลาวด์ Standard เปิดใช้ API และกำหนดค่าแพลตฟอร์มการตรวจสอบสิทธิ์ของ Google อย่างถูกต้อง

  1. เลือกหรือสร้างโปรเจ็กต์: ไปที่ คอนโซล Google Cloud แล้วใช้เมนูแบบเลื่อนลงของโปรเจ็กต์ที่ด้านบนของหน้าเพื่อเลือกโปรเจ็กต์ที่มีอยู่หรือสร้างโปรเจ็กต์ใหม่
  2. เปิดใช้ API: เมื่อโปรเจ็กต์ที่เลือกใช้งานอยู่ในแถบด้านบน ให้เปิดขั้นตอนการเปิดใช้ API แล้วคลิกถัดไปและเปิดใช้สำหรับ Workspace Studio API
  3. กำหนดค่าการสร้างแบรนด์ OAuth: เปิดหน้าการสร้างแบรนด์แพลตฟอร์มการตรวจสอบสิทธิ์ของ Google
    1. หากได้รับข้อความแจ้ง ให้คลิกเริ่มต้นใช้งาน (หากกำหนดค่าไว้แล้ว ให้ข้ามไปยังขั้นตอนที่ 4)
    2. ในส่วนข้อมูลแอป ให้ป้อนชื่อแอปและอีเมลสำหรับการสนับสนุนผู้ใช้ คลิกถัดไป
    3. ในส่วนกลุ่มเป้าหมาย ให้เลือกภายใน (หรือภายนอกหากไม่มีตัวเลือกภายใน) แล้วคลิกถัดไป
    4. ระบุข้อมูลติดต่อ ยอมรับนโยบายข้อมูล แล้วคลิกสร้าง
  4. กำหนดค่าการเข้าถึงข้อมูล: เปิดหน้าการเข้าถึงข้อมูล แล้วคลิกเพิ่มหรือนำขอบเขตออก
    1. ในส่วนเพิ่มขอบเขตด้วยตนเอง ให้วาง https://www.googleapis.com/auth/workspace.studio.trigger
    2. คลิกเพิ่มลงในตาราง แล้วคลิกอัปเดต จากนั้นคลิกบันทึกที่ด้านล่างของหน้า
  5. ไปที่ IAM และผู้ดูแลระบบ > การตั้งค่า (หรือแดชบอร์ด Cloud Console) แล้วคัดลอกหมายเลขโปรเจ็กต์
  6. กลับไปที่โปรเจ็กต์ Apps Script แล้วคลิกการตั้งค่าโปรเจ็กต์ การตั้งค่าโปรเจ็กต์ในแถบด้านข้างซ้าย
  7. ในส่วนโปรเจ็กต์ Google Cloud Platform (GCP) ให้คลิกเปลี่ยนโปรเจ็กต์
  8. ป้อนหมายเลขโปรเจ็กต์ GCP ที่คัดลอกไว้ แล้วคลิกตั้งค่าโปรเจ็กต์

กำหนดค่าไฟล์ Manifest

เปิดไฟล์ appsscript.json ที่เพิ่งปรากฏ แทนที่เนื้อหาด้วยโค้ดด้านล่าง ไฟล์ Manifest นี้แสดงรายการขอบเขต OAuth ที่จำเป็นอย่างชัดเจน และกำหนดเงื่อนไขเริ่มต้นเป็น workflowTrigger และการดำเนินการเป็น workflowAction ภายใต้บล็อก studio.flows.workflowElements

{
  "timeZone": "America/Los_Angeles",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "webapp": {
     "executeAs": "USER_ACCESSING",
     "access": "MYSELF"
  },
  "oauthScopes": [
    "https://www.googleapis.com/auth/script.external_request",
    "https://www.googleapis.com/auth/workspace.studio.trigger",
    "https://www.googleapis.com/auth/script.storage",
    "https://www.googleapis.com/auth/script.locale"
  ],
  "urlFetchWhitelist": [
    "https://workspacestudio.googleapis.com/"
  ],
  "addOns": {
    "common": {
      "name": "Support Extension",
      "logoUrl": "https://www.gstatic.com/images/branding/productlogos/buganizer/v1/192px.svg",
      "useLocaleFromApp": true
    },
    "studio": {
      "flows": {
        "workflowElements": [
          {
            "id": "supportTicketTrigger",
            "state": "ACTIVE",
            "name": "New Support Ticket",
            "description": "Fires when someone submits a ticket via the Web App.",
            "workflowTrigger": {
              "inputs": [],
              "outputs": [
                {
                  "id": "ticketTitle",
                  "description": "The title of the ticket",
                  "cardinality": "SINGLE",
                  "dataType": { "basicType": "STRING" }
                },
                {
                  "id": "ticketDescription",
                  "description": "The full description of the issue",
                  "cardinality": "SINGLE",
                  "dataType": { "basicType": "STRING" }
                }
              ],
              "onConfigFunction": "onConfigTrigger",
              "onManageFunction": "onManageTrigger"
            }
          },
          {
            "id": "urgencyDetectorStep",
            "state": "ACTIVE",
            "name": "Detect Urgency",
            "description": "Scans the ticket description to detect High or Normal urgency.",
            "workflowAction": {
              "inputs": [
                {
                  "id": "ticketDescription",
                  "description": "The ticket description",
                  "cardinality": "SINGLE",
                  "dataType": { "basicType": "STRING" }
                }
              ],
              "outputs": [
                {
                  "id": "urgencyLevel",
                  "description": "The urgency High/Normal",
                  "cardinality": "SINGLE",
                  "dataType": { "basicType": "STRING" }
                }
              ],
              "onConfigFunction": "onConfigUrgency",
              "onExecuteFunction": "onExecuteUrgency"
            }
          }
        ]
      }
    }
  }
}

3. สร้าง UI ของเว็บแอป

เราจะสร้างเว็บแอป Apps Script เพื่อให้วิธีที่มองเห็นได้และทดสอบได้ในการเรียกใช้โปรแกรมเริ่มต้นโดยไม่ต้องใช้เครื่องมือเทอร์มินัลหรือเว็บบุ๊กของบุคคลที่สาม

ในเครื่องมือแก้ไขสคริปต์ของ Apps Script ให้คลิก เพิ่มไฟล์ เพิ่มไฟล์ข้างไฟล์ แล้วเลือก HTML ตั้งชื่อว่า index.html (ระบบจะเพิ่มส่วนขยาย .html โดยอัตโนมัติ)

วางโค้ด UI แบบเรียบง่ายต่อไปนี้

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <style>
      body { font-family: Arial, sans-serif; padding: 20px; max-width: 500px; margin: auto; }
      label { font-weight: bold; display: block; margin-top: 15px; }
      input, textarea { width: 100%; margin-top: 5px; padding: 10px; box-sizing: border-box; }
      button { background-color: #1a73e8; color: white; border: none; padding: 10px 15px; margin-top: 15px; font-weight: bold; cursor: pointer; border-radius: 4px; }
      button:hover { background-color: #1557b0; }
      #status { margin-top: 15px; color: green; font-weight: bold; }
    </style>
  </head>
  <body>
    <h2>Support Quick Portal</h2>
    <p>Submit your issue below to trigger the Workspace Studio flow.</p>

    <label for="title">Ticket Title</label>
    <input type="text" id="title" placeholder="e.g. Broken monitor">

    <label for="description">Issue Description</label>
    <textarea id="description" rows="4" placeholder="Explain your issue (use words like 'urgent' to test the step!)..."></textarea>

    <button onclick="submitTicket()">Submit Ticket</button>
    <div id="status"></div>

    <script>
      function submitTicket() {
        const title = document.getElementById('title').value;
        const description = document.getElementById('description').value;
        const statusEl = document.getElementById('status');

        if (!title || !description) {
           statusEl.style.color = "red";
           statusEl.innerText = "Please fill out both fields.";
           return;
        }

        statusEl.style.color = "green";
        statusEl.innerText = "Submitting ticket...";

        google.script.run
          .withSuccessHandler(function(response) {
            statusEl.innerText = response;
          })
          .withFailureHandler(function(error) {
            statusEl.style.color = 'red';
            statusEl.innerText = 'Error: ' + error.message;
          })
          .submitTicketToStudio(title, description);
      }
    </script>
  </body>
</html>

4. สร้างสคริปต์แบ็กเอนด์

ตอนนี้เรามาเชื่อมต่อทุกอย่างเข้าด้วยกัน เราจะแยก Web App, ตรรกะของ Starter และตรรกะของ Action Step ออกเป็นไฟล์สคริปต์ 3 ไฟล์เพื่อให้โค้ดอ่านง่าย

WebApp.gs

เปลี่ยนชื่อไฟล์ Code.gs เริ่มต้นในเอดิเตอร์เป็น WebApp.gs ลบ myFunction ที่เป็นบอยเลอร์เพลต แล้วคัดลอกและวางบล็อกด้านล่างลงในไฟล์ ไฟล์นี้จัดการการโฮสต์เว็บแอป

/** --- WEB APP HOSTING --- **/

/**
 * Serves the HTML UI when users visit the web app URL.
 */
function doGet() {
  return HtmlService.createHtmlOutputFromFile('index')
      .setTitle('Support Quick Portal')
      .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

/**
 * Called by the Web App form. It calls the Workspace Studio API.
 */
function submitTicketToStudio(title, description) {
  const props = PropertiesService.getUserProperties();
  const notifyUri = props.getProperty('notifyUri');
  const triggerId = props.getProperty('triggerId');

  if (!notifyUri || !triggerId) {
    throw new Error('Trigger URL missing! Make sure the flow is enabled in Workspace Studio.');
  }

  // Use ScriptApp.getOAuthToken() (requires the workspace.studio.trigger scope in manifest)
  const token = ScriptApp.getOAuthToken();
  const requestId = Utilities.getUuid();

  // Package our outputs mapped in appsscript.json
  const payload = {
    "name": "triggers/" + triggerId,
    "outputs": {
      "ticketTitle": { "stringValues": [title] },
      "ticketDescription": { "stringValues": [description] }
    },
    "requestId": requestId
  };

  const options = {
    "method": "POST",
    "contentType": "application/json",
    "headers": { "Authorization": "Bearer " + token },
    "payload": JSON.stringify(payload),
    "muteHttpExceptions": true
  };

  // Fire!
  const response = UrlFetchApp.fetch(notifyUri, options);
  if (response.getResponseCode() !== 200) {
    console.error(response.getContentText());
    throw new Error('Workspace Studio API Error: ' + response.getResponseCode());
  }
  return 'Ticket successfully routed to Workspace Studio!';
}

Starter.gs

จากนั้นวางเมาส์เหนือไฟล์ คลิก เพิ่มไฟล์ เพิ่มไฟล์ เลือกสคริปต์ แล้วตั้งชื่อว่า Starter.gs คัดลอกและวางบล็อกด้านล่างลงในไฟล์ ไฟล์นี้จัดการการกำหนดค่า Starter และการจัดการวงจรของ Workspace Studio

/** --- STARTER LOGIC --- **/

/**
 * Workspace Studio calls this to display the config UI when the user adds the starter.
 * We just return a static message since there are no properties to configure.
 */
function onConfigTrigger() {
  const section = CardService.newCardSection()
      .setHeader("Configure Web App Starter")
      .addWidget(CardService.newTextParagraph().setText("Ready to go! Once you enable this flow, deploy your Apps Script project as a Web App to submit tickets."));

  return CardService.newCardBuilder().addSection(section).build();
}

/**
 * Workspace Studio posts data here to manage the lifecycle (enable/disable the trigger).
 * Critically, we must construct or save the `notifyUri` and `triggerId` to call it later.
 */
function onManageTrigger(event) {
  const triggerCreation = event.workflow.triggerCreation;
  const triggerDeletion = event.workflow.triggerDeletion;

  const props = PropertiesService.getUserProperties();

  if (triggerCreation) {
    // Save the unique URL and ID when the flow is enabled
    // Note: notifyUri might be omitted, so fallback to constructing it dynamically
    const notifyUri = triggerCreation.notifyUri || `https://workspacestudio.googleapis.com/v1/triggers/${triggerCreation.triggerId}:fire`;
    props.setProperty('notifyUri', notifyUri);
    props.setProperty('triggerId', triggerCreation.triggerId);
  } else if (triggerDeletion) {
    // Cleanup if the user deletes the flow
    props.deleteProperty('notifyUri');
    props.deleteProperty('triggerId');
  }
}

Action.gs

จากนั้นวางเมาส์เหนือไฟล์ คลิก เพิ่มไฟล์ เพิ่มไฟล์ เลือกสคริปต์ แล้วตั้งชื่อว่า Action.gs คัดลอกและวางตรรกะของขั้นตอนความเร่งด่วนด้านล่างลงในช่อง

/** --- ACTION STEP LOGIC --- **/

/**
 * Workspace Studio configuration card for the Step.
 * We prompt the user to bind a variable to our "ticketDescription" input.
 */
function onConfigUrgency() {
  const input = CardService.newTextInput()
      .setFieldName("ticketDescription")
      .setTitle("Source Description")
      .setHint('Select the description variable outputted by the starter')
      .setHostAppDataSource(
        CardService.newHostAppDataSource().setWorkflowDataSource(CardService.newWorkflowDataSource().setIncludeVariables(true))
      );

  const section = CardService.newCardSection()
      .setHeader("Urgency Detector Step")
      .addWidget(input);

  return CardService.newCardBuilder().addSection(section).build();
}

/**
 * The synchronous logic executed during the Step.
 */
function onExecuteUrgency(event) {
  // Read mapped inputs
  let description = event.workflow.actionInvocation.inputs["ticketDescription"].stringValues[0];
  if (!description) description = "";

  const urgentKeywords = ['urgent', 'crash', 'broken', 'down', 'fire'];
  let urgencyLevel = 'Normal';

  if (urgentKeywords.some(keyword => description.toLowerCase().includes(keyword))) {
    urgencyLevel = 'High';
  }

  // Package outputs correctly
  const variableDataMap = {
    "urgencyLevel": AddOnsResponseService.newVariableData().addStringValue(urgencyLevel)
  };

  return outputVariables(variableDataMap);
}

/**
 * Helper strictly enforcing the expected Step object return type.
 */
function outputVariables(variableDataMap) {
  const workflowAction = AddOnsResponseService.newReturnOutputVariablesAction()
      .setVariableDataMap(variableDataMap);
  const hostAppAction = AddOnsResponseService.newHostAppAction()
      .setWorkflowAction(workflowAction);
  return AddOnsResponseService.newRenderActionBuilder()
      .setHostAppAction(hostAppAction)
      .build();
}

5. ติดตั้งใช้งานและทดสอบ

เมื่อเขียนโค้ดแล้ว เรามาติดตั้งใช้งานโปรเจ็กต์และกำหนดค่ากัน

ขั้นตอนที่ 1: ให้สิทธิ์สคริปต์อีกครั้ง

เนื่องจากคุณลิงก์โปรเจ็กต์ที่อยู่ในระบบคลาวด์ Google Cloud มาตรฐานใหม่ คุณจึงต้องให้สิทธิ์ขอบเขตของสคริปต์อย่างชัดเจน (เช่น script.external_request ที่ใช้โดย UrlFetchApp) กับโปรเจ็กต์ใหม่

  1. ในเครื่องมือแก้ไขสคริปต์ของ Apps Script ให้เลือก WebApp.gs ในส่วนไฟล์ จากนั้นเลือกฟังก์ชัน doGet จากเมนูแบบเลื่อนลงของแถบเครื่องมือด้านบน
  2. คลิกเรียกใช้
  3. ข้อความแจ้ง "ต้องมีการให้สิทธิ์" จะปรากฏขึ้น คลิกตรวจสอบสิทธิ์
  4. เลือกบัญชีและให้สิทธิ์สคริปต์ หากเห็นคำเตือน "แอปที่ไม่ได้รับการยืนยัน" ให้คลิกขั้นสูง -> ไปที่พอร์ทัลด่วนสำหรับการสนับสนุนเพื่อข้าม
  5. รอให้บันทึกการดำเนินการแสดงการดำเนินการเสร็จสมบูรณ์ ซึ่งจะยืนยันว่าตอนนี้สคริปต์ได้รับอนุญาตอย่างเต็มรูปแบบแล้ว

ขั้นตอนที่ 2: ทดสอบส่วนขยายและเว็บแอป

เนื่องจาก appsscript.json ของคุณกำหนดทั้งส่วนเสริมและเว็บแอป คุณจึงกำหนดค่าทั้ง 2 อย่างพร้อมกันได้

  1. คลิกติดตั้งใช้งาน > ทดสอบการติดตั้งใช้งานที่มุมขวาบนของ Apps Script
  2. ข้างเลือกประเภท ให้คลิก เปิดใช้ประเภทการติดตั้งใช้งาน เปิดใช้ประเภทการติดตั้งใช้งาน แล้วตรวจสอบว่าได้เลือกส่วนเสริมของ Google Workspace แล้ว จากนั้นคลิกติดตั้ง
  3. คลิกเปิดใช้ประเภทการติดตั้งใช้งาน เปิดใช้ประเภทการติดตั้งใช้งานอีกครั้ง ตรวจสอบว่าได้เลือกเว็บแอปแล้ว และคัดลอก URL (จะลงท้ายด้วย /dev) นี่คือ URL สำหรับเว็บแอปพอร์ทัลด่วนสำหรับฝ่ายสนับสนุนที่คุณสร้างขึ้น
  4. คลิกเสร็จสิ้น คุณอาจต้องรีเฟรชเบราว์เซอร์ก่อนที่ Workspace Studio จะลงทะเบียนส่วนเสริม

ขั้นตอนที่ 3: กำหนดค่าโฟลว์ของ Studio

  1. เปิด Google Workspace Studio ที่ studio.workspace.google.com
  2. คลิก เพิ่มเครื่องมือ Add tool ทางด้านซ้าย แล้วเลือก Flow
  3. หากต้องการกำหนดค่า Starter ให้คลิกเลือก Starter จากนั้นเลือก Support Extension ที่ติดตั้งไว้ > คำขอแจ้งปัญหาใหม่ หากได้รับข้อความ "ต้องมีสิทธิ์" ให้คลิกให้สิทธิ์เพื่อให้ส่วนเสริมเข้าถึงข้อมูลของคุณได้
  4. จากนั้นในส่วนการดำเนินการ ให้คลิกเลือกขั้นตอน เลื่อนไปที่ "ส่วนขยายการสนับสนุน" แล้วเลือกขั้นตอนตรวจหาความเร่งด่วน
  5. ในคำอธิบายแหล่งที่มา ให้คลิก เพิ่ม ตัวแปร แล้วเลือกขั้นตอนที่ 1: คำขอแจ้งปัญหาใหม่ > คำอธิบายแบบเต็มของปัญหา (ticketDescription)
  6. คลิกเลือกขั้นตอนอีกครั้ง แล้วเลือกขั้นตอนในตัว เช่น Gmail > ส่งอีเมล หรือ Chat > แจ้งเตือนฉันใน Chat
    • หากเลือก Gmail ให้ทำดังนี้
      • ถึง: ใส่อีเมลของคุณเอง
      • เรื่อง: ตั๋วticketTitleมีลำดับความสำคัญเป็น urgencyLevel
      • ข้อความ: ticketDescription
    • หากเลือกแชท
      • ข้อความ: ตั๋วมีticketTitleลำดับความสำคัญเป็นurgencyLevel ticketDescription
  7. เปิดเวิร์กโฟลว์ หากได้รับแจ้งให้เปลี่ยนชื่อโฟลว์ ให้ป้อนชื่อ เช่น Support Ticket Router แล้วบันทึก ซึ่งจะทริกเกอร์วงจรของ onManageTrigger และบันทึก notifyUri

ขั้นตอนที่ 4: เรียกใช้การจำลอง

  1. เปิด URL ของเว็บแอปที่คัดลอกไว้ก่อนหน้านี้ในขั้นตอนที่ 2 ของหน้านี้ในแท็บเบราว์เซอร์ใหม่ (URL จะลงท้ายด้วย /dev)
  2. กรอกข้อมูลในแบบฟอร์ม ตรวจสอบว่าคุณได้ใส่คีย์เวิร์ดทริกเกอร์ (เช่น "ด่วน" หรือ "ขัดข้อง") ในคำอธิบาย
  3. คลิกส่ง รอข้อความ "ส่งต่อคำขอแจ้งปัญหาสำเร็จ"
  4. ตรวจสอบบันทึกกิจกรรมของ Workspace Studio, กล่องจดหมาย Gmail หรือ Google Chat (ขึ้นอยู่กับการดำเนินการที่คุณเลือก) คุณควรเห็นข้อความหรืออีเมลที่ติดแท็กเป็น"สูง" ซึ่งผสานรวมโดยกำเนิดโดยใช้องค์ประกอบ Apps Script ที่กำหนดเอง

6. ล้าง

หากต้องการหลีกเลี่ยงไม่ให้พื้นที่ทำงานและบัญชี Google Cloud รก คุณสามารถล้างทรัพยากรที่สร้างขึ้นระหว่าง Codelab นี้ได้

  1. ลบโฟลว์ Workspace Studio:
    • เปิด studio.workspace.google.com
    • ค้นหาSupport Ticket Routerโฟลว์
    • คลิกเมนู 3 จุดข้างวิดีโอ แล้วเลือกลบ
  2. ลบโปรเจ็กต์ Apps Script:
    • ไปที่ script.google.com
    • ค้นหาโปรเจ็กต์ Support Quick Portal
    • คลิกเมนู 3 จุด แล้วเลือกนำออก
  3. ปิดโปรเจ็กต์ Google Cloud:
    • ไปที่คอนโซล Google Cloud
    • ตรวจสอบว่าได้เลือกโปรเจ็กต์ใหม่ในเมนูแบบเลื่อนลงด้านบน
    • ไปที่ IAM และผู้ดูแลระบบ > การตั้งค่า แล้วคลิกปิด

7. บทสรุป

คุณสร้างระบบนิเวศที่สมบูรณ์แบบสำหรับส่วนขยายที่กำหนดเองของ Google Workspace Studio ได้สำเร็จโดยไม่ต้องอาศัยการสมัครใช้บริการของบุคคลที่สามภายนอก

สิ่งที่เราพูดถึง

  • การใช้ workflowTrigger ควบคู่กับ onManageFunction เพื่อบันทึกและจัดการเหตุการณ์วงจรของ Google อย่างถูกต้อง
  • การตรวจสอบสิทธิ์คำขอแบ็กเอนด์โดยใช้ ScriptApp.getOAuthToken() กับปลายทาง API ของ workspacestudio.googleapis.com
  • การใช้ workflowAction เพื่อประมวลผลตัวแปรอินพุตแบบซิงโครนัสและสร้างเอาต์พุตดาวน์สตรีม

ตอนนี้คุณสามารถเพิ่มโหนดหลักการเหล่านี้เพื่อเชื่อมต่อกับแพลตฟอร์ม SaaS จริง เช่น Jira, Salesforce หรือ Zendesk ได้โดยการแก้ไขตำแหน่งที่เว็บแอป (หรือ Webhook ขาเข้า) ทริกเกอร์