> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gnani.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Email Integration and Action

> Allow agents to send emails

Integrate your email provider with Gnani Agents to automatically send personalized emails — such as welcome messages, follow-ups, newsletters, and transactional notifications — without manual effort.

***

## **1. Why Integrate Email?**

By connecting an email service to Gnani Agents, your agent can:

* **Send automated welcome emails** when a new customer signs up.
* Deliver **follow-up sequences** after calls.
* Share **newsletters, offers, or promotions** at the right moment.
* Trigger **transactional emails** (order confirmations, invoices, etc.) instantly.

***

## **2. Set Up Email Integration**

You can integrate with either **Mailchimp** or **SendGrid** depending on your preference.

***

### **Option 1 — Mailchimp Integration**

1. **Open Integration Settings**
   * Go to **Add Email Integration** in your Gnani Agents dashboard.
   * Select **Mailchimp** as the operator and provide an integration name.
2. **Get Your API Key**
   * Log in to your Mailchimp account.
   * Go to **Account → Extras → API Keys**.
   * Create or copy an existing **API Key**.
3. **Add API Key to** Gnani Agents
   * Paste the Mailchimp API Key into the integration form in Gnani Agents.
4. **Save**
   * Click **Save** to complete the integration.

***

### **Option 2 — SendGrid Integration**

1. **Create or Log Into Your Account**
   * Go to [SendGrid](https://sendgrid.com) and sign up or log in.
2. **Create an API Key**
   * In your SendGrid dashboard, go to **Settings → API Keys**.
   * Click **Create API Key**.
   * Name it (e.g., *Platform Integration*).
   * Set **API Key Permissions** to **Full Access** or at least **Mail Send**.
   * Click **Create & View** — copy this key (you won’t see it again later).
   * Paste it into Gnani Agents' **API Key** field.
3. **Add & Verify Your Sender Email**
   **Option A — Single Sender Verification (Quick)**
   * Go to **Settings → Sender Authentication → Verify Single Sender**.
   * Enter your sender email (e.g., `support@yourdomain.com`) and details.
   * Click the verification link sent to your email.
   * Use this sender email in Gnani Agents.
     **Option B — Domain Authentication (Recommended for Production)**
   * If you manage your domain’s DNS, choose **Domain Authentication**.
   * SendGrid will give you **CNAME records** to add to your DNS.
   * Once verified, you can send from any address on that domain.
4. **Save**
   * Click **Save** to complete the integration.

***

## **3. Create an Email Action**

1. **Navigate to Actions**
   * Go to **Manage Agents → Select Agent → Action Tab**.
2. **Create Action**
   * Click **+** to open the **Create Action** card.
3. **Fill in Details**
   * **Name:** Use only letters, numbers, or underscores.
   * **Description:** Describe when the action should trigger.
     * Example: *"Trigger this action when the user provides their email for newsletter signup."*
4. **Select Integration**
   * Choose your Mailchimp or SendGrid integration.
5. **Choose Trigger**
   * **Post-Call:** Executes after the conversation ends.
     * If **Post-Call** is selected, you can:
       * Add **Variables** (sent to the API).
   * **On-Call:** Executes during the conversation.
     * If **On-Call** is selected, you can:
       * Write a message in the **Speak During Action** section.
       * Add **Before API Call Variables** (sent to the API).
       * Add **After API Call Variables** (received from the API).
6. **Set Email-Specific Fields**
   * **Select Action:** Select the default option *(Contact us for support for multiple Mailchimp actions)*
   * **Template Name:** Select a Mailchimp email template to use.
   * **From Name & Email:** The verified sender name and email in Mailchimp.
   * **To Name & Email:** The recipient’s details. Variable input is recommended (e.g., `{{customer_name}}`, `{{customer_email}}`).
   * **Add Subject:** Custom subject line — can include variables.
   * **Merge Variables:** Map Gnani Agents variables to Mailchimp template placeholders:
     * **Key:** Variable name in Mailchimp template.
     * **Value:** Corresponding Gnani Agents variable (e.g., `{{order_id}}`).

***

## **4. Test Your Email Action**

Testing ensures your emails are triggered correctly before going live.

1. **Open Testing Mode**
   * Go to **Manage Agents → Select Agent → Test**.
2. **Start a Test Conversation**
   * Speak or chat with your agent in the test interface.
3. **Trigger the Action**
   * Use the same instructions or keywords from your Action’s **Description** to activate it.
4. **Check Your Email**
   * Verify that the email is received by the intended recipient.
   * Confirm that template variables are replaced correctly with actual data.
5. **Check Action Logs**
   * In Gnani Agents, click **More Options (⋮)** on the Action card → **View Logs**.
   * Review the logs for execution details and any API errors.

***

✅ **Your Email integration is now ready!** Your agent can send beautifully designed, personalized emails using Mailchimp or SendGrid directly from conversations.
