ROOPON Logo
autogen

AutoGen + ROOPON API - Build a Microsoft AutoGen Agent That Earns Commission

By ROOPON Team5 min read

Microsoft AutoGen has matured into one of the more capable multi-agent orchestration frameworks available to developers. Its strength is not in any single agent doing everything - it is in coordinating specialised agents that each do one thing well. That same design principle maps cleanly onto affiliate marketing: research is a different job from writing, which is a different job from publishing. When you split those responsibilities across agents, each one becomes more reliable.

This post walks through building a three-agent AutoGen pipeline that earns affiliate commission through the ROOPON API. The pipeline runs on a schedule, produces Australian savings content, registers affiliate links, and publishes without manual intervention.

How AutoGen's Agent Model Works

AutoGen's core primitive is the ConversableAgent. You configure each agent with a system message that defines its role, then you let agents pass messages to each other until a task is complete. The UserProxyAgent is a special variant that can execute code or call tools on behalf of the conversation.

For an affiliate earning pipeline you need three roles:

  1. A researcher that finds current Australian savings topics worth writing about
  2. A writer that produces useful content around those topics
  3. A publisher that calls the ROOPON API, gets the affiliate claim URL, and embeds it in the final output

Setting Up the Environment

pip install pyautogen requests python-dotenv

Store your ROOPON credentials in a .env file:

ROOPON_AGENT_SECRET=your_agent_secret
OPENAI_API_KEY=your_openai_key

Defining the Three Agents

import os
import json
import requests
from dotenv import load_dotenv
import autogen

load_dotenv()

config_list = [
    {
        "model": "gpt-4o",
        "api_key": os.getenv("OPENAI_API_KEY"),
    }
]

llm_config = {"config_list": config_list, "temperature": 0.4}

# Agent 1: Researcher
researcher = autogen.AssistantAgent(
    name="Researcher",
    system_message="""You are an Australian savings researcher.
    Your job is to identify current, relevant savings topics for Australian households
    and consumers - think groceries, utilities, subscriptions, fuel, insurance, and loyalty programmes.
    Produce a brief on a single topic with 3–5 key points a reader would find genuinely useful.
    Do not fabricate specific prices or statistics. Use ranges and typical figures.""",
    llm_config=llm_config,
)

# Agent 2: Writer
writer = autogen.AssistantAgent(
    name="Writer",
    system_message="""You are a content writer specialising in Australian personal finance.
    You receive a research brief and produce a 400–500 word article that is helpful,
    direct, and written in Australian English. No emojis. No excessive marketing language.
    End the article with a placeholder [AFFILIATE_LINK] where the ROOPON link will be inserted.""",
    llm_config=llm_config,
)

# Agent 3: Publisher (with tool access)
publisher = autogen.UserProxyAgent(
    name="Publisher",
    human_input_mode="NEVER",
    max_consecutive_auto_reply=3,
    code_execution_config={"work_dir": "output", "use_docker": False},
    system_message="""You are a publisher agent. You receive finished article content,
    call the ROOPON API to get an affiliate claim URL, replace the [AFFILIATE_LINK]
    placeholder, and output the final article ready for publishing.""",
)

Registering with the ROOPON API

The ROOPON Agent API is straightforward - a single POST to register your agent and receive your affiliate claim URL:

def register_roopon_agent(agent_name: str, topic: str) -> dict:
    """Register an agent session with ROOPON and retrieve the affiliate claim URL."""
    response = requests.post(
        "https://www.roopon.com/api/v1/agents/register",
        json={
            "agent_name": agent_name,
            "topic": topic,
            "secret": os.getenv("ROOPON_AGENT_SECRET"),
        },
        headers={"Content-Type": "application/json"},
        timeout=15,
    )
    response.raise_for_status()
    return response.json()  # Returns: {"api_key": "...", "claim_url": "..."}


def embed_affiliate_link(content: str, topic: str) -> str:
    """Get ROOPON affiliate link and embed it into the article."""
    data = register_roopon_agent(agent_name="AutoGen-Savings-Agent", topic=topic)
    claim_url = data["claim_url"]

    affiliate_section = (
        f"\n\nIf you want to put these savings strategies into practice, "
        f"ROOPON members across Australia get access to exclusive partner discount codes "
        f"and included prize-draw entries (see /giveaways). Membership costs $19.99/month. "
        f"[Learn more and join here]({claim_url})."
    )

    return content.replace("[AFFILIATE_LINK]", affiliate_section)

Running the Multi-Agent Pipeline

def run_affiliate_pipeline(topic_hint: str = "Australian grocery savings 2026"):
    """Orchestrate the full research → write → publish pipeline."""

    # Step 1: Research
    researcher_chat = researcher.initiate_chat(
        publisher,
        message=f"Research this topic and produce a brief: {topic_hint}",
        max_turns=2,
    )
    research_brief = researcher_chat.summary

    # Step 2: Write
    writer_chat = writer.initiate_chat(
        publisher,
        message=f"Write an article based on this brief:\n\n{research_brief}",
        max_turns=2,
    )
    draft_content = writer_chat.summary

    # Step 3: Publish with affiliate link
    final_content = embed_affiliate_link(draft_content, topic=topic_hint)

    # Save to file (or post to your CMS/API)
    output_path = f"output/{topic_hint[:40].replace(' ', '_')}.md"
    os.makedirs("output", exist_ok=True)
    with open(output_path, "w") as f:
        f.write(final_content)

    print(f"Article published: {output_path}")
    return final_content


if __name__ == "__main__":
    run_affiliate_pipeline("How Australians can reduce their power bill in 2026")

Why the Multi-Agent Split Matters

A single agent asked to research, write, and publish in one pass typically compromises on all three. The researcher drifts into writing mode; the writer skips research. With AutoGen's explicit agent boundaries, each system message is short and focused, which keeps outputs higher quality.

The publisher agent being a UserProxyAgent with code execution enabled means it can run the ROOPON API call as actual Python code rather than just pretending to. That is a meaningful distinction in a production pipeline.

Commission Structure

ROOPON pays 40% recurring commission on the $19.99/month Basic membership. Every reader who joins through your affiliate link contributes to your monthly recurring income for as long as they remain a member. An automated pipeline like this can publish content consistently without the effort scaling linearly with output.

Next Steps

Schedule the pipeline with a cron job or a task scheduler like APScheduler. Add a topic rotation list so the agent works through different Australian savings categories systematically. Log each article's affiliate link so you can track which topics convert best.


Ready to add the ROOPON monetisation layer to your AutoGen agents? Start at https://www.roopon.com/ai-agents and consult the full API reference at https://www.roopon.com/docs/agents.

Keep reading

Related posts

Save smarter with ROOPON membership

Member discounts, deals, and giveaways per campaign terms — from $19.99/month.

Become a member