Skip to main content

Tutorial – Building a Multi-Agent System with Email Sending on Pupau

Overview

This tutorial will guide you step-by-step in building a multi-agent workflow on Pupau featuring collaboration between agents and automated email sending as shown in our YouTube Tutorial. You'll learn how to configure “tagging” (one agent calling another), set up a robust email tool, and create agent prompts to orchestrate the entire back-office flow. This recipe is tailored for scenarios such as sales, support, or inventory—where data retrieved by one agent must be processed and sent via email by another but you can use this pattern for any other use case.


1. Introduction

Multi-agent collaboration on Pupau enables the orchestration of two or more intelligent agents, each specializing in different tasks. In this pattern, for example, a Back Office Agent coordinates with a Commercial (or Inventory) Agent to gather data, format a report, and deliver it via email. This is ideal for business tasks like periodic reporting, stock availability checks, customer info sharing, or other communication-intensive processes.

2. Create the Back Office (Main) Agent

  1. Log in to Pupau: Open Pupau with the proper permissions.

  2. Create a New Assistant:

    • Click Create New Assistant (+ button).
    • Name: E.g., Back Office Collaborator.
    • Description: "Coordinates with commercial agents to generate reports and send emails."
    • Model: Choose GPT-4.1 Global or your preferred model.
    • System Prompt: Leave a placeholder for now.
    • Features: Keep attachments and multi-agent orchestration enabled.

3. Add and Configure Tools

a) Agent Tagging Tool (Agent Orchestrator)

This tool allows your agent to involve automatically another agent in the conversation. In our example we are using it to tag the commercial agent and receive the info about Products and Customers.

  • Type: Agent Orchestrator/Agent-as-a-Tool

  • Name: database_check

  • Description: "Run this tool to tag the commercial agent and receive the info about Products and Customers"

  • Setup:

    • Select the Commercial/Inventory Agent you want to tag (must already exist in your Pupau workspace).
    • Choose "Tagging" mode as the orchestration flow.
    • Enable attachments if needed.
    • (Optional) Adjust message limits or advanced settings as required.

    Tagging vs Handover:
    With Tagging, the main agent asks the secondary agent a question, receives the answer, and resumes control of the conversation/workflow.
    With Handover, the original agent hands off the task completely, and the secondary agent continues independently.

b) Email Sending Tool

We are using the native email tool of Pupau setting both the sender and the recipient. You can customize the email tool to fit your needs, choosing to fix the sender and/or the recipient or leave them dynamic to be set by the agent, depending on your use case.

  • Type: Native or External (SMTP/Email API)
  • Name: send_email
  • Description: "Sends emails with report content to preconfigured recipients."
  • Setup:
    • Configure server address, port, and authentication—per your organization’s email infrastructure.
    • Set (or leave dynamic) the subject, recipient, and sender fields.
    • Map tool parameters for content/body (to accept data generated in previous steps).
    • (Optional) If you want fixed recipients or subjects (e.g. [email protected], or "Daily Inventory Report") fill them here; leave dynamic if each task will specify them.

4. System Prompt

Define the behavior of your back office agent and outline the collaboration flow. Here you can find an example of system prompt that you can use as a starting point.

<instructions>
<usage_info>

# AI Assistant commercial and back office

## Identity and Purpose

You are a knowledgeable, helpful and friendly assistant that provides accurate information. You are an assistant in commercial and back office operations, you are able to tag other agents to retrieve the data that you need. Your approach is:


##task

1. Tag the commercial assistant (call as a tool) agent to receive the data of the product to elaborate.
2. Create a report of the products to send via email with body and subject in a good formal text and font, ready to go out or presentation
3. Send the report by email


## Available Tools

- ** database_check ** : Tag the commercial assistant sg agent and receive info about Products and Customers. It will receive your context and will return the data of the products and customers.
- ** send_email **: send an email with your final report with all the data you have recovered in good formal text and font, ready to go out or presentation. Use HTML format for the body of the email.

## Initial Setup Process
1. When the user asks which products are available, check the list of products with the commercial assistant agent to receive the data of the products by starting the tool: database_check (tagging the back office agent and receiving the product data)
giving to him this type of query:
id (INT, chiave primaria auto_increment)
name (VARCHAR 255, nome del prodotto)
description (VARCHAR 2048, descrizione del prodotto)
quantity (INT, quantità disponibile)
2. when you have received the data of the product from the commercial assistant sg agent start automatically or at least ask to user if you can start to create a draft of an email to send with all the data of the products and then do it automatically.
3. Show the draft to the user, ask if it is OK or needs modifications, and when the user confirms go to the next step
4. When you have generated the body (in good formal text and font, ready to go out or presentation) and the subject of the final email, send an email with the final result using the tool: send_email
</instructions>

5. Multi-Agent Interaction Flow

Here’s a typical operational sequence for this use case:

  1. The main (Back Office) agent receives a user/business request ("Which products are currently in stock?")
  2. The agent invokes the Commercial Agent using the tagging tool (database_check), requesting a list or report.
  3. The Commercial Agent responds with the requested data.
  4. The Back Office Agent formats the information into a report—optionally as a table, HTML, or plain text.
  5. The agent uses the email tool (send_email) to send the report to a manager, client, or internal address.

6. Email Formatting & Attachments

  • You can instruct your Back Office Agent (via prompt or workflow) to format emails as plain text, HTML, or with tables—and to include attachments if needed. In our example we are using HTML format for the body of the email.
  • Optionally, set up placeholders/templates for different scenarios ("Send me the detailed list," "Email the report to my supervisor," etc.).

7. Example Interactions

Test your workflow with these prompts:

  • "What products are available in the warehouse? Please email the list to my address."
  • "Send a detailed report about stock with quantities for all products."
  • "Forward the product sheet for [Product Name] via email."

The agent should retrieve the requested data, format it, and send it via email (with logs confirming each step’s completion).

8. Testing Tips & Troubleshooting

  • Adjust formatting in your agent’s prompt if the output isn’t as desired (e.g., improve tables or details in email body).
  • Double-check the email configuration: SMTP server, port, credentials, and permissions.
  • Review the workflow logs if the multi-agent tagging or handover fails.
  • Use Pupau’s test tools (i.e. Pipelines) to simulate the process before production rollout.

9. Security & Best Practices

  • Never expose email credentials in prompts or plain text—always use Pupau’s credentials vault.
  • Enforce access controls: only authorized users and agents can trigger high-privilege actions such as emailing or tagging.
  • Monitor logs for compliance and troubleshooting.

10. Next Steps

  • Refine agent prompts and report templates as your business logic evolves.
  • Add further agents (for analytics, follow-up, CRM updates, etc.) to extend your collaborative workflows.
  • Explore folders, custom actions, and agent orchestration for larger business processes.

You are now set up to automate reports, streamline inter-agent collaboration, and send critical communications with a few clicks on Pupau!