How is your experience with the OutSystems Community?
mailchimp-connector
Service icon

Mailchimp Connector

Stable version 2.0.0 (Compatible with OutSystems 11)
Uploaded
 on 24 Nov (3 days ago)
 by 
5.0
 (2 ratings)
mailchimp-connector

Mailchimp Connector

Details
Connect OutSystems 11 apps to Mailchimp: audiences, members, tags, merge fields, segments, campaigns, templates, reports, automations and batch operations through the Mailchimp Marketing API 3.0.
Read more

Requirements

  • OutSystems 11 (11.8 or later).
  • A Mailchimp account. Some features need a paid plan: scheduling, cancel-send, timewarp and some automations.
  • No other Forge dependencies.


API key setup

  1. In Mailchimp, open your profile, then Extras, then API keys.
  2. Click Create A Key, give it a name and copy it. Mailchimp shows it only once.
  3. The key looks like 0123456789abcdef0123456789abcdef-us7. The part after the dash (us7) is your data center.
  4. The key has the permissions of the user who created it. Use an admin user when you can.

Configuration (Service Center, module MailchimpConnector, Site Properties)

  • ApiKey (Secret): the Mailchimp API key.
  • ServerPrefix (optional): the data center, for example us7. Leave it empty to take it from the key. Set it when you use an OAuth 2 access token instead of a key.

Set them in each environment. Never put the key in code, in client variables or in inputs that come from the browser.

How to use

  • In your module, open Manage Dependencies, select MailchimpConnector and add the actions and structures you need.
  • Call the action from server-side logic and check Success.
  • When Success is False, read ErrorCode and ErrorMessage. Errors has the validation errors per field. ResponseJSON has the full Mailchimp answer.


Check the connection:

  • Call Ping. Success = True and Response.HealthStatus = "Everything's Chimpy!" mean the key is valid. ErrorCode 401 means the key is wrong.


Add or update a contact:

  • Call CreateOrUpdateMember with AudienceId (from ListAudiences), MemberKey = "ana@example.com", Member.EmailAddress = "ana@example.com" and Member.StatusIfNew = "subscribed".
  • Member.MergeFields.FName = "Ana" sets the first name.
  • MergeFieldsJSON = {"COMPANY":"Acme"} sets other merge fields by tag (see ListMergeFields).
  • To ask for confirmation by email, use Member.StatusIfNew = "pending".


Tag a contact:

  • Call UpdateMemberTags with a list of TagUpdate: Name = "customer", Status = "active". Use Status = "inactive" to remove the tag.


List all members:

  • Call ListMembers with Count = 1000 and Offset = 0.
  • Repeat with Offset = Offset + Count while Offset < TotalItems.


Send a campaign:

  1. Call CreateCampaign with Campaign.Type = "regular", Campaign.Recipients.ListId and Campaign.Settings (SubjectLine, FromName, ReplyTo).
  2. Call SetCampaignContent with CampaignId = Response.Id and CampaignContent.Html.
  3. Call GetSendChecklist and check Response.IsReady.
  4. Call SendTestEmail, then SendCampaign, or ScheduleCampaign with a UTC time on a quarter hour.

Options without a typed input:

  • Use AdditionalJSON to add raw JSON members to the request body. For example "interests":{"abc123":true} on a member, or "double_optin":false on an audience.


Demo app (MailchimpConnectorDemo)

  • Setup: API key steps, connection test (GetAccount: account, role, plan, subscribers) and a map of the demo.
  • Audiences and Audience: create, delete, statistics, settings, merge fields, tags and segments, interest categories, webhooks.
  • Members and Member: list by status with paging, search, upsert, status, merge fields, tags, notes, activity, custom events, archive and GDPR delete.
  • Campaigns and Campaign: drafts, HTML content, send checklist, test email, send, schedule, unschedule, cancel, replicate, resend to non-openers, delete, report with clicks and opens.
  • Templates, Automations (classic automations, queue, customer journey trigger) and Advanced (batch subscribe, batch operations).
  • Every screen shows the last call: operation, HTTP status, error message, errors per field and the raw JSON response.
  • The demo acts on your real Mailchimp account. Use a test audience.


Supported methods

  • Account: Ping, GetAccount.
  • Audiences: ListAudiences, GetAudience, CreateAudience, UpdateAudience, DeleteAudience, BatchSubscribeMembers.
  • Members: ListMembers, GetMember, AddMember, CreateOrUpdateMember, UpdateMember, ArchiveMember, DeleteMemberPermanently, SearchMembers, ListMemberTags, UpdateMemberTags, ListMemberActivity, ListMemberNotes, AddMemberNote, DeleteMemberNote, AddMemberEvent.
  • Merge fields: ListMergeFields, GetMergeField, CreateMergeField, UpdateMergeField, DeleteMergeField.
  • Segments and tags: ListSegments, GetSegment, CreateSegment, UpdateSegment, DeleteSegment, ListSegmentMembers, AddSegmentMember, RemoveSegmentMember, SearchTags.
  • Interests: ListInterestCategories, CreateInterestCategory, UpdateInterestCategory, DeleteInterestCategory, ListInterests, CreateInterest, UpdateInterest, DeleteInterest.
  • Webhooks: ListWebhooks, GetWebhook, CreateWebhook, UpdateWebhook, DeleteWebhook.
  • Campaigns: ListCampaigns, GetCampaign, CreateCampaign, UpdateCampaign, DeleteCampaign, GetCampaignContent, SetCampaignContent, GetSendChecklist, SendCampaign, SendTestEmail, ScheduleCampaign, UnscheduleCampaign, ReplicateCampaign, CancelCampaign, CreateResendCampaign.
  • Templates: ListTemplates, GetTemplate, CreateTemplate, UpdateTemplate, DeleteTemplate.
  • Reports: ListCampaignReports, GetCampaignReport, ListCampaignOpens, ListCampaignClicks, ListCampaignUnsubscribes, ListCampaignEmailActivity.
  • Automations: ListAutomations, GetAutomation, StartAutomation, PauseAutomation, ListAutomationEmails, AddSubscriberToAutomation, TriggerJourneyStep.
  • Batch operations: CreateBatch, GetBatch, ListBatches, DeleteBatch.


Error handling

  • ErrorCode is the HTTP status returned by Mailchimp:
    • 400: invalid data or a rule was broken, for example Member Exists (see Errors and ErrorMessage);
    • 401: API key missing or invalid;
    • 403: the user of the key cannot do this, or the account is disabled;
    • 404: not found;
    • 405: method not allowed for this resource, for example deleting a sent campaign;
    • 429: too many requests. Mailchimp allows 10 simultaneous connections per key. Wait and try again;
    • 5xx: Mailchimp error. Try again later.
  • ErrorCode -1 means an unexpected error, for example a timeout or an empty ApiKey. ErrorMessage has the exception message and the error is logged.


Notes

  • MemberKey accepts the email address, the subscriber hash (MD5 of the lowercase email) or the contact id.
  • Ids and dates are returned as Text, as the API returns them. Dates are in ISO 8601.
  • Empty and False values are not sent, so they keep the Mailchimp defaults. Use AdditionalJSON to send an explicit false.
  • Mailchimp Transactional (Mandrill) is a separate API with its own key and is not included.
Release notes (2.0.0)

New

  • 87 public actions (19 before). New areas: account, merge fields, segments and tags, interests, webhooks, templates, reports, classic automations, customer journeys and batch operations.
  • Members: upsert (CreateOrUpdateMember), update, permanent delete (GDPR), search, tags, notes, activity feed and custom events. Audiences: update and batch subscribe.
  • Campaigns: update, set content, send checklist, schedule, unschedule, replicate, cancel and resend.
  • Pagination on lists: Count and Offset inputs, TotalItems output. Before, lists returned only the first 10 records.
  • AdditionalJSON on every request with a body, for options without a typed input. MergeFieldsJSON on members.
  • Descriptions on every action, parameter, structure, attribute and site property.
  • New demo app (MailchimpConnectorDemo): one screen per area, HTTP status and raw JSON of each call.

Improved

  • Same outputs on every action: Success, ErrorCode (HTTP status), ErrorMessage, Errors and ResponseJSON. Errors no longer raise exceptions.
  • Timeouts per method: 30 s, and 60 s for batch operations.
  • The data center is taken from the API key (or the ServerPrefix site property), so any Mailchimp account works.

Security

The API key is no longer stored in the module. It is read from the Secret site property ApiKey and sent as a Bearer token.

Breaking changes

  • Not compatible with 1.0.0: structures and outputs changed.
  • Renamed actions: GetLists > ListAudiences, GetListById > GetAudience, CreateUpdateList > CreateAudience (and UpdateAudience), DeleteList > DeleteAudience, GetMembersByListId > ListMembers, AddMemberToList > AddMember, ChangeMemberStatus > UpdateMember, RemoveListMember > ArchiveMember (and DeleteMemberPermanently), GetCampaigns > ListCampaigns, GetCampaignById > GetCampaign, ReSendCampaign > CreateResendCampaign.
  • Removed: SubscribeMember and UnsubscribeMember (use CreateOrUpdateMember or UpdateMember with Status), the MemberStatus static entity, the TenantId and TenantName site properties and the structures List, Address, CampaignToCreate and STR_*.

Upgrading from 1.0.0

  1. Create an API key in Mailchimp and set ApiKey in Service Center.
  2. Refresh the dependency and fix each call: new names, new inputs and outputs.
  3. Replace exception handlers with checks on Success and ErrorCode.
License (2.0.0)
Reviews (0)
Team
Other assets in this category