Skip to content

title: "n8n Integration with Appgain.io" description: "Complete guide to integrate n8n workflows with Appgain.io SMS, WhatsApp, Email, and Push Notification APIs" keywords: ["n8n", "workflow automation", "Appgain.io", "SMS", "WhatsApp", "Email", "Push Notifications", "API integration"] tags: ["integrations", "automation", "n8n", "api"] author: "Appgain.io Team" date: "2024-01-15"


n8n Integration with Appgain.io

Overview

n8n is a powerful workflow automation platform that can integrate seamlessly with Appgain.io's omni-channel messaging APIs. This guide provides comprehensive examples for automating SMS, WhatsApp, Email, and Push Notification campaigns through n8n workflows.

Authentication

All Appgain.io API requests require: - API Key: Your project's API key (sent as appapikey header) - Project ID: Your Appgain project identifier

Base URLs

https://notify.appgain.io/{{projectId}}/send
https://automator.appgain.io/automessages/{{projectId}}/firevent

SMS Integration

Use Case 1: Automated Order Confirmation SMS

  • Scenario*: Send SMS confirmation when a customer places an order.

  • n8n Workflow*:

  • Trigger: Webhook (Order placed)
  • Action: HTTP Request (Send SMS)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "SMS": {
    "message": "Order #{{orderId}} confirmed! Track at {{trackingUrl}}",
    "receivers": [
      {
        "userID": "{{customerId}}",
        "mobileNum": "{{customerPhone}}"
      }
    ]
  }
}

Use Case 2: Bulk SMS Campaign

  • Scenario*: Send promotional SMS to all subscribed users.

  • n8n Workflow*:

  • Trigger: Schedule (Daily at 10 AM)
  • Action: HTTP Request (Send bulk SMS)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "SMS": {
    "message": "🎉 50% OFF today! Use code SALE50",
    "target_list_name": "promotional_subscribers"
  }
}

Use Case 3: SMS Verification Code

  • Scenario*: Send verification codes for user authentication.

  • n8n Workflow*:

  • Trigger: User registration
  • Action: HTTP Request (Send verification SMS)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "SMS": {
    "message": "Your verification code is: {{verificationCode}}",
    "receivers": [
      {
        "userID": "{{userId}}",
        "mobileNum": "{{phoneNumber}}"
      }
    ]
  }
}

WhatsApp Business API Integration

Use Case 1: Customer Support Chat

  • Scenario*: Send automated responses to customer inquiries.

  • n8n Workflow*:

  • Trigger: Webhook (Customer message received)
  • Action: HTTP Request (Send WhatsApp response)

  • Postman Example*:

Create Template

curl --location 'https://notify.appgain.io/{{projectId}}/create_whatsapp_template' \
- **-header 'Authorization**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiVGthbXVsV0JTIiwidXNlcm5hbWUiOiJUa2FtdWxXQlMiLCJleHAiOjE3NDU5MjcyMDksIm9yaWdfaWF0IjoxNzQ1OTIzNjA5LCJjdXN0b21lcl9pZCI6IkI3SVprU1JTRjhEcSIsInNlbmRfbWVzc2FnZSI6ZmFsc2UsInJlc2VsbGVyIjpmYWxzZX0.2y24-jhBJ-L4eLSt98RtF5yKsfPJMWIG4BA2mi6pG4g' \
- **-header 'Content-Type**: application/json' \
- **-header 'authToken**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDU4MzIzNDIsImlhdCI6MTc0NTc0NTk0Miwic3ViIjoiNjQwODgzN2Q2MWFlMWIwMDEzN2RjZTkyIn0.4mfk95X0yWkGHFJ2HIccWq9-1TjCvLaApZaIcVpDGO4' \
- -data '{
    "template_name": "customer_support",
    "language": [
        "en"
    ],
    "template_category": "UTILITY",
    "template_type": "template",
    "components": {
        "body": {
            "text": "🟢  Thanks {{1}} for contacting us! We'll respond within 24 hours",
            "example": [
                "doha",
            ]
        },
        "header": {
            "type": "text",
            "text": "hello"
        },
        "buttons": {
            "type": "combined_buttons",
            "elements": [
                {
                    "label": "working?",
                    "type": "static",
                    "website": "https://unsplash.com/"
                }
            ]
        }
    }
}'

Send Messgae

curl --location 'https://notify.appgain.io/{{projectId}}/send' \
- **-header 'appapikey**: {{api_key}}' \
- **-header 'Content-Type**: application/json' \
- **-header 'Authorization**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiVGthbXVsV0JTIiwidXNlcm5hbWUiOiJUa2FtdWxXQlMiLCJleHAiOjE3NDgzNjA0MzYsIm9yaWdfaWF0IjoxNzQ4MzU2ODM2LCJjdXN0b21lcl9pZCI6IkI3SVprU1JTRjhEcSIsInNlbmRfbWVzc2FnZSI6ZmFsc2UsInJlc2VsbGVyIjpmYWxzZX0.lTREzv-v_tIEbMDRc3hfX328xHEMwMgBOAkUJpo909g' \
- -data '{
    "WHATSAPP": {
        "vendor": "routemobile",
        "parameters": {
            "body": [
                {
                    "text": "user"
                }
            ],
            "imageUrl":"https://cdn.appgain.io/6408837d61ae1b00137dce92/backenddev/6zCRj.jpg"


        },
        "template_name": "customer_support",
        "lang_code": "en",
        "receivers": [
            {
                "mobileNum": "{{mobileNum}}"
            }


        ]
    }
}'

Use Case 2: Order Status Updates

  • Scenario*: Send order status updates via WhatsApp.

  • n8n Workflow*:

  • Trigger: Database change (Order status updated)
  • Action: HTTP Request (Send WhatsApp notification)

  • Postman Example*:

Create Template

curl --location 'https://notify.appgain.io/{{projectId}}/create_whatsapp_template' \
- **-header 'Authorization**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiVGthbXVsV0JTIiwidXNlcm5hbWUiOiJUa2FtdWxXQlMiLCJleHAiOjE3NDU5MjcyMDksIm9yaWdfaWF0IjoxNzQ1OTIzNjA5LCJjdXN0b21lcl9pZCI6IkI3SVprU1JTRjhEcSIsInNlbmRfbWVzc2FnZSI6ZmFsc2UsInJlc2VsbGVyIjpmYWxzZX0.2y24-jhBJ-L4eLSt98RtF5yKsfPJMWIG4BA2mi6pG4g' \
- **-header 'Content-Type**: application/json' \
- **-header 'authToken**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDU4MzIzNDIsImlhdCI6MTc0NTc0NTk0Miwic3ViIjoiNjQwODgzN2Q2MWFlMWIwMDEzN2RjZTkyIn0.4mfk95X0yWkGHFJ2HIccWq9-1TjCvLaApZaIcVpDGO4' \
- -data '{
    "template_name": "order_update",
    "language": [
        "en"
    ],
    "template_category": "UTILITY",
    "template_type": "template",
    "components": {
        "body": {
            "text": "Your order #{{orderId}} is now {{status}}",
            "example": [
                "123456",
                "pending"
            ]
        },
        "header": {
            "type": "text",
            "text": "hello"
        },
        "buttons": {
            "type": "combined_buttons",
            "elements": [
                {
                    "label": "working?",
                    "type": "static",
                    "website": "https://unsplash.com/"
                }
            ]
        }
    }
}'

Send Messgae

curl --location 'https://notify.appgain.io/{{projectId}}/send' \
- **-header 'appapikey**: {{api_key}}' \
- **-header 'Content-Type**: application/json' \
- **-header 'Authorization**: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiVGthbXVsV0JTIiwidXNlcm5hbWUiOiJUa2FtdWxXQlMiLCJleHAiOjE3NDgzNjA0MzYsIm9yaWdfaWF0IjoxNzQ4MzU2ODM2LCJjdXN0b21lcl9pZCI6IkI3SVprU1JTRjhEcSIsInNlbmRfbWVzc2FnZSI6ZmFsc2UsInJlc2VsbGVyIjpmYWxzZX0.lTREzv-v_tIEbMDRc3hfX328xHEMwMgBOAkUJpo909g' \
- -data '{
    "WHATSAPP": {
        "vendor": "routemobile",
        "parameters": {
            "body": [
                {
                   "text": "123456",
                "text":"pending"
                }
            ],
            "imageUrl":"https://cdn.appgain.io/6408837d61ae1b00137dce92/backenddev/6zCRj.jpg"


        },
        "template_name": "order_update",
        "lang_code": "en",
        "receivers": [
            {
                "mobileNum": "{{mobileNum}}"
            }


        ]
    }
}'

WhatsApp Lite Integration

Use Case 1: Quick Notifications

  • Scenario*: Send lightweight notifications without rich media.

  • n8n Workflow*:

  • Trigger: Schedule (Hourly updates)
  • Action: HTTP Request (Send WhatsApp Lite)

  • Postman Example*:

curl --location 'https://notify.appgain.io/{{projectId}}/send' \
- **-header 'appapikey**: {{api_key}}' \
- -data '{
    "UOWHATSAPP": {
        "message": "test Quick Notifications",
        "random_string": 1,
        "imageUrl": "https://via.placeholder.com/300x200.png",
       "documentUrl": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
        "receivers": [
            {
                "mobileNum": "{{mobileNum}}"
            }
        ]
    }
}'

Email Integration

Use Case 1: Welcome Email Series

  • Scenario*: Send automated welcome emails to new users.

  • n8n Workflow*:

  • Trigger: User registration
  • Action: HTTP Request (Send welcome email)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "email": {
    "message": "<h1>Welcome {{userName}}!</h1><p>Thank you for joining us.</p>",
    "template_name": "welcome_email",
    "subject": "Welcome to Our Platform",
    "type": "HTML",
    "receivers": [
      {
        "userID": "{{userId}}",
        "email": "{{userEmail}}"
      }
    ]
  }
}

Use Case 2: Newsletter Campaign

  • Scenario*: Send weekly newsletter to all subscribers.

  • n8n Workflow*:

  • Trigger: Schedule (Every Friday at 9 AM)
  • Action: HTTP Request (Send newsletter)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "email": {
    "message": "{{newsletterHtml}}",
    "template_name": "weekly_newsletter",
    "subject": "This Week's Updates",
    "type": "HTML"
  }
}

Use Case 3: Abandoned Cart Recovery

  • Scenario*: Send reminder emails for abandoned shopping carts.

  • n8n Workflow*:

  • Trigger: Database query (Abandoned carts)
  • Action: HTTP Request (Send recovery email)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "email": {
    "message": "<h2>Complete Your Purchase</h2><p>Your cart is waiting for you!</p>",
    "template_name": "cart_recovery",
    "subject": "Don't forget your cart!",
    "type": "HTML",
    "receivers": [
      {
        "userID": "{{userId}}",
        "email": "{{userEmail}}"
      }
    ]
  }
}

Push Notifications Integration

Use Case 1: Breaking News Alerts

  • Scenario*: Send immediate push notifications for breaking news.

  • n8n Workflow*:

  • Trigger: RSS feed (News update)
  • Action: HTTP Request (Send push notification)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "appPush": {
          "message": "Test Message",
          "campaignName": "Test Campaign",
          "selectedType": "text",
          "type": "text",
          "localization": {
            "name": "English",
            "code": "en",
            "selected": true,
            "important": true
          },
          "receivers": [
            {
              "userID": "{{userId}}"
            }
          ],
          "targetUserIds": "{{userId}}",
          "targetType": "userId",
          "title": "Test Title",
          "optionals": {
            "title": "Optional Title"
          }
        },
        "campaign_name": "Test Campaign",
        "campaign_id": "6746073951a302a688b77058"
}

Use Case 2: Rich Media Push Notifications

  • Scenario*: Send push notifications with images and deep links.

  • n8n Workflow*:

  • Trigger: Product launch
  • Action: HTTP Request (Send rich push)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "appPush": {
          "message": "New Product Available!",
          "sound": "default",
          "campaignName": "product_launch",
          "type": "photo",
          "mutable-content": 1,
          "url": "https://yourapp.com/product/{{productId}}",
          "campaignName": "Test Campaign",
          "selectedType": "text",
          "type": "text",
          "localization": {
            "name": "English",
            "code": "en",
            "selected": true,
            "important": true
          },
          "receivers": [
            {
              "userID": "{{userId}}"
            }
          ],
          "targetUserIds": "{{userId}}",
          "targetType": "userId",
          "title": "Test Title",
          "optionals": {
            "title": "Optional Title"
          }
        },
        "campaign_name": "Test Campaign",
        "campaign_id": "6746073951a302a688b77058"
}

Use Case 3: Silent Push Notifications

  • Scenario*: Send background data updates without user notification.

  • n8n Workflow*:

  • Trigger: Data sync (Background update)
  • Action: HTTP Request (Send silent push)

  • Postman Example*:

POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{

"appPush": {
          "message": "New Product Available!",
          "sound": "",
          "campaignName": "product_launch",
          "type": "photo",
          "mutable-content": 1,
          "url": "https://yourapp.com/product/{{productId}}",
          "campaignName": "Test Campaign",
          "selectedType": "text",
          "type": "text",
          "localization": {
            "name": "English",
            "code": "en",
            "selected": true,
            "important": true
          },
          "receivers": [
            {
              "userID": "{{userId}}"
            }
          ],
          "targetUserIds": "{{userId}}",
          "targetType": "userId",
          "title": "Test Title",
          "optionals": {
            "title": "Optional Title"
          }
        },
        "campaign_name": "Test Campaign",
        "campaign_id": "6746073951a302a688b77058"
}

Automation Integration

Use Case 1: Trigger Automated Campaigns

  • Scenario*: Fire automation messages based on user actions.

  • n8n Workflow*:

  • Trigger: User action (Purchase completed)
  • Action: HTTP Request (Fire automation)

  • Postman Example*:

curl --location 'https://devopsautomator.appgain.io/automessages/{{projectId}}/firevent/v2/purchase_completed' \
- **-header 'appApiKey**: {{api_key}}' \
- **-header 'Content-Type**: application/json' \
- -data '{
    "users": [
        {
            "userId": "{{userId}}"
        },
        {
            "userId": "{{userId}}"
        }
    ]
}'


Use Case 2: Cancel Automation Messages

  • Scenario*: Cancel scheduled automation messages.

  • n8n Workflow*:

  • Trigger: User request (Cancel subscription)
  • Action: HTTP Request (Cancel automation)

  • Postman Example*:

DELETE https://automator.appgain.io/automessages/{{projectId}}/firevent/v2/purchase_completed
Headers:
  appApiKey: {{api_key}}
- -data '{
    "users": [
        {
            "userId": "{{userId}}"
        },
        {
            "userId": "{{userId}}"
        }
    ]
}'

n8n Environment Variables

Set these in your n8n environment:

APPGAIN_PROJECT_ID=your_project_id
APPGAIN_API_KEY=your_api_key
APPGAIN_BASE_URL=https://notify.appgain.io
APPGAIN_AUTOMATOR_URL=https://automator.appgain.io

Complete n8n Workflow Example

E-commerce Order Processing Workflow

// 1. Webhook Trigger (Order placed)
const orderData = {
  orderId: "ORD-12345",
  customerId: "CUST-67890",
  customerEmail: "customer@example.com",
  customerPhone: "+1234567890",
  total: 99.99
};

// 2. Send SMS Confirmation
const smsRequest = {
  method: "POST",
  url: "https://notify.appgain.io/{{$json.projectId}}/send",
  headers: {
    "Content-Type": "application/json",
    "appapikey": "{{$json.apiKey}}"
  },
  body: {
    "SMS": {
      "message": `Order #${orderData.orderId} confirmed! Total: $${orderData.total}`,
      "receivers": [
        {
          "userID": orderData.customerId,
          "mobileNum": orderData.customerPhone
        }
      ]
    }
  }
};

// 3. Send Email Receipt
const emailRequest = {
  method: "POST",
  url: "https://notify.appgain.io/{{$json.projectId}}/send",
  headers: {
    "Content-Type": "application/json",
    "appapikey": "{{$json.apiKey}}"
  },
  body: {
    "email": {
      "message": `<h1>Order Confirmation</h1><p>Order #${orderData.orderId}</p>`,
      "template_name": "order_receipt",
      "subject": "Order Confirmation",
      "type": "HTML",
      "receivers": [
        {
          "userID": orderData.customerId,
          "email": orderData.customerEmail
        }
      ]
    }
  }
};


// 4. Send Push Notification
POST https://notify.appgain.io/{{projectId}}/send
Headers:
  Content-Type: application/json
  appapikey: {{api_key}}

Body:
{
  "appPush": {
          "message": "Order confirmed! Track your delivery",
          "sound": "default",
          "campaignName": "product_launch",
          "type": "photo",
          "mutable-content": 1,
          "url": "https://yourapp.com/product/{{productId}}",
          "campaignName": "Test Campaign",
          "selectedType": "text",
          "type": "text",
          "localization": {
            "name": "English",
            "code": "en",
            "selected": true,
            "important": true
          },
          "receivers": [
            {
              "userID": "{{userId}}"
            }
          ],
          "targetUserIds": "{{userId}}",
          "targetType": "userId",
          "title": "Test Title",
          "optionals": {
            "title": "Optional Title"
          }
        },
        "campaign_name": "Test Campaign",
        "campaign_id": "6746073951a302a688b77058"
}


// 5. Fire Automation (Follow-up campaign)
curl --location 'https://devopsautomator.appgain.io/automessages/{{projectId}}/firevent/v2/purchase_completed' \
- **-header 'appApiKey**: {{api_key}}' \
- **-header 'Content-Type**: application/json' \
- -data '{
    "users": [
        {
            "userId": "{{userId}}"
        },
        {
            "userId": "{{userId}}"
        }
    ]
}'

Best Practices

  1. Error Handling: Always implement error handling for API failures
  2. Rate Limiting: Respect API rate limits and implement delays
  3. Template Management: Use consistent template names across campaigns
  4. User Segmentation: Target specific user segments for better engagement
  5. A/B Testing: Test different message formats and timing
  6. Analytics: Track delivery rates and user engagement
  7. Compliance: Ensure compliance with messaging regulations

Troubleshooting

Common Issues

  1. Authentication Errors: Verify API key and project ID
  2. Rate Limiting: Implement exponential backoff
  3. Template Errors: Ensure template names exist in Appgain dashboard
  4. User ID Issues: Verify user IDs are valid and active
  5. Network Errors: Implement retry logic for failed requests

Debug Tips

  1. Test with Postman: Use Postman collection for API testing
  2. Check Logs: Monitor n8n execution logs
  3. Validate Data: Ensure all required fields are present
  4. Test Small: Start with small user segments
  5. Monitor Metrics: Track delivery and engagement rates

Resources


  • This integration guide provides comprehensive examples for automating Appgain.io messaging campaigns through n8n workflows. For additional support, contact the Appgain.io team.*
C
Ask ChatGPT about Appgain
📝 Last updated: July 28, 2025 14:37:02