const response = await fetch("https://mino.ai/v1/automation/run-sse", {
method: "POST",
headers: {
"X-API-Key": process.env.MINO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://example.com/contact",
goal: `Fill in the contact form:
- Name field: "John Doe"
- Email field: "john@example.com"
- Message field: "I am interested in your services."
Then click the Submit button and extract the success message.
`,
}),
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n");
buffer = lines.pop() ?? "";
for (const line of lines) {
if (line.startsWith("data: ")) {
const event = JSON.parse(line.slice(6));
if (event.type === "COMPLETE" && event.status === "COMPLETED") {
console.log("Result:", event.resultJson);
}
}
}
}