Closed as not planned
Description
Shopify scraping agent
shopify_agent = Agent(
name="shopify_agent",
instructions="""You are a Shopify product scraping specialist.
When given a shopify URL, you must:
1. Use scrape_shopify_collection to get the product data
2. Return ONLY the scraped product data as a JSON array
Do not add any extra text or explanations.
Do not ask for additional functionality.
Just return the raw product data array.
""",
tools=[scrape_shopify_collection, extract_product_data],
handoff_description="Extract product data from shopify_url using the scrape_shopify_collection tool."
)
data_writer_agent
data_writer_agent = Agent(
name="data_writer_agent",
instructions="""You are a Google Sheets data writing specialist.
When given product data and a sheet URL, you must:
1. Use save_to_sheet to write the data
2. Return ONLY the success/failure message
Do not add any extra text or explanations.
Do not modify the input data.
Just save and return the status message.
""",
tools=[save_to_sheet],
handoff_description="Saves product data to Google Sheets using tool save_to_sheet."
)
#triage_agent
triage_agent = Agent(
name="Triage Agent",
instructions="""You coordinate scraping and saving Shopify product data.
Follow these steps exactly:
1. Parse the input JSON to get shopify_url and sheet_url
2. Hand off to shopify_agent with ONLY the shopify_url
3. Take the product data array returned by shopify_agent
4. Prepare the input for the data_writer_agent in the format:
{"sheet_url": "<sheet_url_value>", "products": <product_data_array>}
Make sure <sheet_url_value> is the sheet_url parsed in step 1.
Make sure <product_data_array> is the data returned in step 3.
5. Hand off to data_writer_agent with the prepared input from step 4.
6. Return the final save status message from data_writer_agent.
IMPORTANT: Do not add extra explanations or text.
Just coordinate the data flow between agents and return the final result of the save operation.
""",
handoffs=[shopify_agent, data_writer_agent]
)
URL's INPUT
shopify_url = "Paste any Shopify_ecommerce_website_link "
sheet_url = "Your Google sheet url"
Main execution function
async def main(shopify_url, sheet_url):
input_data = {
"shopify_url": shopify_url,
"sheet_url": sheet_url,
}
import json
stringify= json.dumps(input_data)
# Print for debugging
print(f"Starting workflow with input: {stringify}")
# Run the triage agent with the input
result = await Runner.run(
triage_agent,
input=stringify,
run_config=config)
return result
if name == "main":
import asyncio
final_output= asyncio.run(main(shopify_url, sheet_url))
print(final_output)