產品指南
基礎
自動化指南
集成指南
AI應用與模板指南
Open API
功能參考
自動化觸發器
自動化執行器
第三方集成
節點資源
數據表視圖
數據表字段
儀表板組件
智能任務
AI 向導
公式
空間站
更新日誌
Videos

運行腳本操作指南

該自動化功能允許用戶在指定的編程語言環境中執行代碼片段。目前,我們支援以下三種編程語言:JavaScript、TypeScript 和 Python。

配置步驟詳述

為了使用此功能,用戶需準備好相應的腳本文件,這些腳本應採用 JavaScript、TypeScript 或 Python 語言編寫。

1. 寫作腳本

用戶可以直接在 BIKA 腳本編輯器中進行腳本的寫作。請注意,必須明確指定期望腳本使用的編程語言:JavaScript、TypeScript 或 Python。

2. 配置「運行腳本」動作

請按照以下步驟在 BIKA 自動化界面上配置「運行腳本」動作:

支援的語言及庫

  • JavaScript 及 TypeScript

    • 我們提供 fetchaxios 以及 lodash 等庫的支援。

    • 可以將 JSON 數據回傳至自動化流程中。

      • 示例代碼:

        const str = 'Hello, World!';
        const json = { str };
        json;
        

        JavaScript 示例1

    • 對於異步函數,建議將其封裝於 async function 中,並使用 return關鍵字回傳數據。

      • 示例代碼:

        (async () => {
          const url = 'https://api.exchangerate-api.com/v4/latest/USD';
          const response = await fetch(url);
          if (!response.ok) {
            throw new Error(response.status);
          }
          return await response.json();
        })();
        

        JavaScript 示例2

  • Python

    • 本地支援的庫有 numpyhttpxbs4pandas

    • 不支援 requests 圖庫。

    • 所有的回傳變量都會被輸出至自動化工作流程。

      • 示例代碼:

        import httpx
        url = 'https://api.exchangerate-api.com/v4/latest/USD'
        r = httpx.get(url)
        data = r.json()
        

        Python 示例

3. 設定自動化動作

  1. 在自動化任務編輯頁面新增一個新的動作,然後在動作類型清單中選擇“運行腳本”。

  2. 選擇腳本語言:JavaScript、TypeScript 或 Python。

  3. 在“腳本內容”區域輸入腳本代碼。例如可以運行一個簡單的 Python 腳本來印出“Hello World”:

    print("Hello World")
    
  4. 保存並啟用:完成腳本設定後,請點擊“保存”來保存動作。

4. 执行測試運行

  1. 執行測試

    • 返回至自動化任務界面。
    • 點擊界面底部的“立即運行”按鈕,系統將會根據您的配置執行腳本。
  2. 檢查結果:腳本執行完畢後,您可通過查看運行歷史記錄來確認輸出結果。若腳本順利執行並回傳了預期的結果,則表示配置無誤。

至此,已成功完成「運行腳本」自動化動作的配置與運行。

bika cta

推薦閱讀

推薦AI自動化模板

Program Communications Plan
The Program Communications Plan template is a key strategic document outlining necessary communication strategies and responsibilities for project success. It defines key messages, audiences, channels, and timelines, ensuring all stakeholders are informed and engaged throughout the project lifecycle, crucial for transparency, expectation management, and fostering collaboration
Project Management
This template streamlines project management with centralized tasks, due dates, views, file sharing, comments, and assignee tracking, ensuring teams stay aligned and collaborate effectively in one space.
项目进度管理
通过集中管理项目和任务完成进度和执行情况,利用自动化功能跟进项目任务状态,有助于提高项目管理和任务协作的效率。
Project planning
Even the simplest project has many elements to track. With this comprehensive template, you can easily manage all project elements, ensuring you stay focused and in control throughout the project's lifecycle.
Project tracker
The project tracker template is designed to help teams effectively manage and track project progress. Through this template, users can easily record tasks, assign responsibilities, set deadlines, and update project status in real time.
付款發票定期催收
定期催收已付款發票,確保財務部門及時收到發票,並管理發票數據