app.post("/interact", async (req, res) => {
try {
const { url } = req.body;
const result = await firecrawl.scrape(url, { formats: ['markdown'] });
const scrapeId = result.metadata?.scrapeId;
await firecrawl.interact(scrapeId, { prompt: 'Search for iPhone 16 Pro Max' });
const response = await firecrawl.interact(scrapeId, { prompt: 'Click on the first result and tell me the price' });
await firecrawl.stopInteraction(scrapeId);
res.json({ output: response.output });
} catch (error) {
res.status(500).json({ error: error.message });
}
});