{
  "name": "AI Schedule Assistant",
  "type": "SHARED",
  "summary": "",
  "description": "",
  "tags": [],
  "blogUrl": "",
  "metadata": {},
  "author": "KotrDev",
  "categories": [],
  "pieces": [
    "@activepieces/piece-telegram-bot",
    "@activepieces/piece-google-sheets",
    "@activepieces/piece-http"
  ],
  "flows": [
    {
      "displayName": "AI Schedule Assistant",
      "trigger": {
        "name": "trigger",
        "valid": true,
        "displayName": "New Update",
        "nextAction": {
          "name": "step_1",
          "skip": false,
          "type": "PIECE",
          "valid": true,
          "settings": {
            "input": {
              "auth": "{{connections['GOOGLE_SHEETS_CONNECTION']}}",
              "sheetId": 0,
              "spreadsheetId": "YOUR_SPREADSHEET_ID",
              "first_row_headers": false,
              "includeTeamDrives": false
            },
            "pieceName": "@activepieces/piece-google-sheets",
            "actionName": "get-many-rows",
            "sampleData": {},
            "pieceVersion": "0.17.2",
            "propertySettings": {
              "sheetId": {
                "type": "MANUAL"
              },
              "spreadsheetId": {
                "type": "MANUAL"
              },
              "first_row_headers": {
                "type": "MANUAL"
              },
              "includeTeamDrives": {
                "type": "MANUAL"
              }
            },
            "errorHandlingOptions": {
              "retryOnFailure": {
                "value": false
              },
              "continueOnFailure": {
                "value": false
              }
            }
          },
          "nextAction": {
            "name": "step_4",
            "skip": false,
            "type": "CODE",
            "valid": true,
            "settings": {
              "input": {
                "rows": "{{step_1['output']}}",
                "question": "{{trigger['output']['message']['text']}}"
              },
              "useDeno": true,
              "sampleData": {},
              "sourceCode": {
                "code": "export const code = async (inputs) => {\n  const now = new Date();\n\n  const today = new Intl.DateTimeFormat(\"en-CA\", {\n    timeZone: \"Asia/Bangkok\",\n    year: \"numeric\",\n    month: \"2-digit\",\n    day: \"2-digit\"\n  }).format(now);\n\n  const prompt = `\nวันนี้คือ ${today} (Asia/Bangkok)\n\nคำถามจาก Telegram:\n${inputs.question}\n\nข้อมูลตารางนัดหมาย:\n${JSON.stringify(inputs.rows)}\n\nตอบคำถามเป็นภาษาไทยโดยอ้างอิงข้อมูลตารางเท่านั้น\nห้ามสร้างกิจกรรมที่ไม่มีอยู่จริง\nไม่นับรายการที่ Status เป็น Cancelled\nเรียงกิจกรรมตามวันและเวลา\n`;\n\n  return {\n    body: {\n      model: \"openai/gpt-oss-20b\",\n      messages: [\n        {\n          role: \"system\",\n          content: \"คุณคือ AI ผู้ช่วยตารางนัดหมาย\"\n        },\n        {\n          role: \"user\",\n          content: prompt\n        }\n      ],\n      temperature: 0.2\n    }\n  };\n};",
                "packageJson": "{}"
              },
              "errorHandlingOptions": {
                "retryOnFailure": {
                  "value": false
                },
                "continueOnFailure": {
                  "value": false
                }
              }
            },
            "nextAction": {
              "name": "step_2",
              "skip": false,
              "type": "PIECE",
              "valid": true,
              "settings": {
                "input": {
                  "url": "https://api.groq.com/openai/v1/chat/completions",
                  "body": {
                    "data": "{{step_4['output']['body']}}"
                  },
                  "method": "POST",
                  "headers": {
                    "Content-Type": "application/json",
                    "Authorization": "Bearer YOUR_GROQ_API_KEY"
                  },
                  "authType": "NONE",
                  "body_type": "json",
                  "use_proxy": false,
                  "authFields": {},
                  "failureMode": "continue_none",
                  "queryParams": {},
                  "proxy_settings": {},
                  "followRedirects": false,
                  "response_is_binary": false
                },
                "pieceName": "@activepieces/piece-http",
                "actionName": "send_request",
                "sampleData": {},
                "pieceVersion": "0.12.2",
                "propertySettings": {
                  "url": {
                    "type": "MANUAL"
                  },
                  "body": {
                    "type": "MANUAL",
                    "schema": {
                      "data": {
                        "type": "JSON",
                        "required": true,
                        "displayName": "JSON Body"
                      }
                    }
                  },
                  "data": {
                    "type": "MANUAL"
                  },
                  "method": {
                    "type": "MANUAL"
                  },
                  "headers": {
                    "type": "MANUAL"
                  },
                  "timeout": {
                    "type": "MANUAL"
                  },
                  "authType": {
                    "type": "MANUAL"
                  },
                  "body_type": {
                    "type": "MANUAL"
                  },
                  "use_proxy": {
                    "type": "MANUAL"
                  },
                  "authFields": {
                    "type": "MANUAL",
                    "schema": {}
                  },
                  "failureMode": {
                    "type": "MANUAL"
                  },
                  "queryParams": {
                    "type": "MANUAL"
                  },
                  "proxy_settings": {
                    "type": "MANUAL",
                    "schema": {}
                  },
                  "followRedirects": {
                    "type": "MANUAL"
                  },
                  "response_is_binary": {
                    "type": "MANUAL"
                  }
                },
                "errorHandlingOptions": {
                  "retryOnFailure": {
                    "value": false
                  },
                  "continueOnFailure": {
                    "value": false
                  }
                }
              },
              "nextAction": {
                "name": "step_3",
                "skip": false,
                "type": "PIECE",
                "valid": true,
                "settings": {
                  "input": {
                    "auth": "{{connections['TELEGRAM_BOT_CONNECTION']}}",
                    "format": "None",
                    "chat_id": "{{trigger['output']['message']['chat']['id']}}",
                    "message": "{{step_2['output']['body']['choices'][0]['message']['content']}}",
                    "reply_markup": {},
                    "protect_content": false,
                    "web_page_preview": false,
                    "disable_notification": false
                  },
                  "pieceName": "@activepieces/piece-telegram-bot",
                  "actionName": "send_text_message",
                  "sampleData": {},
                  "pieceVersion": "0.8.1",
                  "propertySettings": {
                    "format": {
                      "type": "MANUAL"
                    },
                    "chat_id": {
                      "type": "MANUAL"
                    },
                    "message": {
                      "type": "MANUAL"
                    },
                    "instructions": {
                      "type": "MANUAL"
                    },
                    "reply_markup": {
                      "type": "MANUAL"
                    },
                    "protect_content": {
                      "type": "MANUAL"
                    },
                    "web_page_preview": {
                      "type": "MANUAL"
                    },
                    "message_thread_id": {
                      "type": "MANUAL"
                    },
                    "instructions_format": {
                      "type": "MANUAL"
                    },
                    "reply_to_message_id": {
                      "type": "MANUAL"
                    },
                    "disable_notification": {
                      "type": "MANUAL"
                    }
                  },
                  "errorHandlingOptions": {
                    "retryOnFailure": {
                      "value": false
                    },
                    "continueOnFailure": {
                      "value": false
                    }
                  }
                },
                "displayName": "Send Text Message",
                "lastUpdatedDate": "2026-10-11T18:51:10.227Z"
              },
              "displayName": "Send HTTP request",
              "lastUpdatedDate": "2026-10-11T18:48:20.165Z"
            },
            "displayName": "Code",
            "lastUpdatedDate": "2026-10-11T18:43:58.651Z"
          },
          "displayName": "Get All Rows",
          "lastUpdatedDate": "2026-10-11T18:16:49.749Z"
        },
        "lastUpdatedDate": "2026-10-11T18:07:11.599Z",
        "type": "PIECE_TRIGGER",
        "settings": {
          "sampleData": {},
          "propertySettings": {
            "update_types": {
              "type": "MANUAL"
            },
            "trigger_notes": {
              "type": "MANUAL"
            }
          },
          "pieceName": "@activepieces/piece-telegram-bot",
          "pieceVersion": "0.8.1",
          "triggerName": "new_telegram_message",
          "input": {
            "auth": "{{connections['TELEGRAM_BOT_CONNECTION']}}",
            "update_types": []
          }
        }
      },
      "valid": true,
      "schemaVersion": "28",
      "notes": []
    }
  ],
  "status": "PUBLISHED"
}
