F&B Insights Stream

Trình đọc và Phân loại Tài liệu F&B từ GCS

Trigger: New File in GCS

Workflow starts instantly when a new file is created in Google Cloud Storage.

Event: watchObjects
Instant Webhook
Filter by File Path

Proceeds only if the file name contains "articles/". Stops otherwise.

Get File Content from GCS

Fetches the raw content of the uploaded file.

Module: google-cloud-storage:objectsGet
AI Step 1: Score F&B Relevance

Gemini AI analyzes the content to score its relevance to the F&B industry on a scale of 1-10.

You are an extremely strict and logical F&B news analyst...
Return ONLY a single valid JSON object:
{
  "chain_of_thought": "...",
  "relevance_score": 10,
  "reason": "..."
}
Parse JSON Response

Extracts the structured data, including 'relevance_score', from the AI's response.

Router: Based on Relevance Score

The workflow splits based on the AI-generated score.

Branch A: Score > 9 (Highly Relevant)
AI Step 2: Extract Data

For highly relevant articles, Gemini AI extracts specific business data points.

You are an API specialized in data extraction...
Required JSON structure:
{
  "meta": { "u": "...", "d": "..." },
  "data": [ { "v": "...", "m": "...", "b": "..." } ]
}

Error Handling

On failure, a message is sent to the #mktfnb channel and the error is ignored.

Parse JSON Data

Parses the extracted meta and data array.

Iterator

Loops through each data point in the 'data' array.

Text Aggregator

Compiles all data rows into a single SQL VALUES string, cleaning each value.

Write to BigQuery

Inserts the aggregated data into the 'us_fnb_so_lieu_thi_truong' table.

INSERT INTO `us_fnb_so_lieu_thi_truong` (...) VALUES (...)

Error Handling

Retries once with a 1-second delay on failure.

Branch B: Score ≤ 9 (Default)
AI Step 3: Summarize Article

Summarizes less relevant articles to extract key information.

You are an expert F&B news analyst...
Required JSON structure:
{
  "noi_dung_chinh": "...",
  "thuong_hieu": "...",
  "url_bai_viet": "...",
  "ngay_bai_viet": "..."
}
Parse JSON Summary

Parses the summarized content.

Parallel Actions

Save Summary to BigQuery

Saves the summary to the 'us_fnb_tom_tat_bai_viet' table.

Error Handling

On failure, sends a notification and ignores the error.

Post to Facebook

Shares the summary and link to the 'Mktfnb' Facebook page.

Post to LinkedIn

Shares a formatted post to LinkedIn.

Disabled

This step is currently disabled in the workflow.