πŸ€·β€β™€οΈUse Case - Example

"Email Summarization" AI Worker

This section outlines the process flowβ€”from development and publication (by the Developer) to customization, deployment, and usage (by the User)β€”for a Worker that helps with Email Summarization Use Case.

User-Developer Flow Diagram

1

Developer: Worker Template implementation & Publication

  • Coding: The developer creates the core logic of the Email Worker using any agentic framework. Autoppia’s standardized interfaces (e.g., Email Integration, LLM Integration) ensure the worker template is compliant and ready for publication.

  • Worker Configuration: Configuration expected by the worker is specified on the worker.yml file.

  • Publishing on Marketplace thorugh Autoppia Developers Studio.

2

User: Configuration & Deployment

  • Users browse the marketplace and select the Email Worker. They configure it by providing secure credentials (e.g., Gmail OAuth) and any other necessary parameters. To configure a worker user must have prepared all his integrations, llms etc on Autoppia Studio. Then, select the specific configuration that must be inyected into the worker. This conf must follow the desgin specified by developer on Worker Config yml file.

  • Deployment: The system merges the worker template with the user’s configuration to create a customized instance that is deployed on Autoppia’s infrastructure in a privacy-preserving manner.

  • Designer Note: Include a flow diagram or step-by-step widget that illustrates the user configuration and deployment process.

3

Anyone: Use Worker and deploy apps based on it

After deployment, the worker can be accessed through multiple channels:

  • The Autoppia SDK

  • Direct API calls

  • The chat interface on Autoppia Chat


Check this sections for more information on how to publish a Worker Template or how to deploy a Worker.

πŸ§‘β€πŸ’»Developer StudioAutoppia Studioβš™οΈWorker Configuration

Worker YML Configuration Example

Worker configuration Yaml file is in charge of specifying what the agent requires to work and what the user will "provide" to the worker.

Below is the Worker Example configuration that explicitly states what the worker expects to work:

agent:
  name: "Email Worker"
  description: "This is an email worker. It can send and read emails automatically."

integration:
  - category: "email"
  - category: "api"

llm: 
  provider: "openai"
  model: "gpt-4o"

vectorstore: 
  provider: "openai"

Email Worker Example Code

https://github.com/autoppia/autoppia_email_worker/blob/main/email_worker/worker.py

class EmailWorker(AIWorker):
    """
    A sample email agent that can process email-related tasks

    Required configurations:
        - email_integration: EmailIntegration
        - llms: Dict containing configured LLM services
        - vectorstores: Dict containing configured vector stores (optional)
    """

    def __init__(self, config: WorkerConfig):
        self.config = config
        self.name = config.name
        self.system_prompt = config.system_prompt
        self.integrations = config.integrations
        self.vectorstores = config.vectorstores
        self.llms = config.llms
        self.agent_executor = None

    def start(self):
        # Get the LLM service based on available providers (openai or anthropic)
        for provider, llm_service in self.llms.items():
            self.llm = llm_service.get_llm()
            break  # Use the first available LLM service
        
        if not self.llm:
            raise RuntimeError("No LLM service configured")

        # Get email integration
        self.email_integration = self.integrations["email"]["Smtp"]        

        self.initialize_toolkits()
            
        self.system_prompt = ChatPromptTemplate.from_messages(
            [
                (
                    "system",
                    f"{self.system_prompt}",
                ),
                ("user", "{input}"),
                MessagesPlaceholder(variable_name="agent_scratchpad"),
            ]
        )

        agent = create_tool_calling_agent(self.llm, self.email_tools, self.system_prompt)
        self.agent_executor = AgentExecutor(
            agent=agent, tools=self.email_tools, verbose=True
        )
            
    def initialize_toolkits(self):
        email_context = EmailContext(
            smtp_server=self.email_integration.smtp_server,
            smtp_port=self.email_integration.smtp_port,
            imap_server=self.email_integration.imap_server,
            imap_port=self.email_integration.imap_port,
            email=self.email_integration.email,
            password=self.email_integration._password,
        )

        self.user_toolkit = UserToolkit(
            toolkit_name="Email",
            context=email_context.__dict__,
            instruction=self.system_prompt,
        )

        self.toolkits = ToolkitList([email_toolkit], [self.user_toolkit])
        self.email_tools = self.toolkits.to_langchain_tools()

    def stop(self) -> None:
        self.agent_executor = None

    def call(self, message: str) -> str:
        if not self.agent_executor:
            raise RuntimeError("Agent not started")

        result = self.agent_executor.invoke({"input": message})
        return result["output"]


Last updated