Add subscribers to Mailchimp
In this example, you will create aXtension to add someone to your Mailchimp subscriber list. |
The Mailchimp API uses basic authentication Identifying the API requestor using a username and password passed in the HTTP header., and passes parameters A piece of information passed to a third-party API during a request. in the query Part of the URL that does not fit into the path structure, and provides additional information or parameters for the request. The query is prefaced by a question mark (?) in the URL, for example: http://example.com?color=blue., body The part of an HTTP request or response that can contain an arbitrary amount of data, such as the content of a form or web page. and path The part of the URL after the hostname that directs the request to a specific resources within the host. For example, the section after "example.com" in http://example.com/this/is/a/path. to edit and control your mailing list. In this example, we will add a new subscriber to your mailing list when they qualify as a good prospect.
The complete OpenAPI Specification A Nintex-specific OpenAPI Specification key that allows special functionality within Nintex Xtensions. and icon for this example are available here.
The Mailchimp API
Mailchimp is a marketing automation platform that allows you to create sequences of emails ("campaigns") to send a list of recipients ("members"). You can create complex sequences that are sent depending on aspects of your recipient list, such as your assessment of them as a prospect, or their actions, such as purchasing a product, or clicking a link.
You can also store information such as the member's company, preferences, or any other information you need in merge fields. These merge fields can be used to segment your list, and display different campaigns or information to different members.
More information can be found at Mailchimp.com
Set up your Mailchimp account
Sign up to Mailchimp and set up the list that will contain your recipients and the emails you will send them:
- Sign up to Mailchimp
Create your Mailchimp account here: Sign up to Mailchimp.
- Create your list
Lists in Mailchimp house the recipients of your emails: your members.
Note: It is recommended that you use only one list for all your automation, but if you already use Mailchimp you may want to create a separate list to test this example.
- Create the welcome campaign.
Create a campaign to be sent to your newly-qualified prospects to welcome them to your company. The campaign should be triggered when a member is added to your list.
Find your API key
In Mailchimp, your API key not only allows access to your account, it dictates which base URL you should use in your OpenAPI file.
Create an API key to use with Nintex Automation Cloud.
See Where do I find my Mailchimp API key? (Mailchimp help).
Find your API data center
Each Mailchimp account uses one of several data centers for API calls. The data center name is in your API key after the dash. For example, in the API key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us19, the data center is us19. You will use the data center when writing the host section of your OpenAPI Specification.
Create the Open API Specification
Build an OpenAPI Specification that:
- Uses HTTPSto access the host The domain name of the third-party API's URL.[dc].api.mailchimp.com, where [dc] is replaced with your data center name. For example, us19.api.mailchimp.com.
- Uses the base path of /3.0 and basic authentication.
- Uses a GET method on the path The part of the URL after the hostname that directs the request to a specific resources within the host. For example, the section after "example.com" in http://example.com/this/is/a/path./lists with no parameters, and a response containing an array of objects with the properties name and id.
- Uses a POST method on the path /lists/{listID}/members with the ID of the list as a parameter in the path
using x-ntx-dynamic-values, and an object in the body with the new
member's details:
- Email address as a string.
- Status as a string enum with the option of subscribed.
- merge fields as an object with two string properties of FNAME and LNAME, the new member's first and last name.
For more information on using x-ntx-dynamic-values, see x-ntx-dynamic-values
Note: If additionalProperties is not defined for an object, it defaults to true, allowing workflow designers to add arbitrary properties to that object.
{
"swagger": "2.0",
"info": {
"description": "Mailchimp Api",
"version": "1.0.0",
"title": "Mailchimp Api",
"contact": {}
},
"host": "<dc>.api.mailchimp.com",
"basePath": "/3.0",
"schemes": [ "https" ],
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"security": [
{
"Basic authentication": []
}
],
"paths": {
"/lists": {
"get": {
"summary": "Get Lists",
"operationId": "getLists",
"description": "List all lists in this account",
"parameters": [],
"responses": {
"200": {
"description": "Status 200",
"schema": {
"type": "object",
"properties": {
"lists": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"/lists/{listID}/members": {
"post": {
"summary": "Add a new member",
"operationId": "addMember",
"description": "Add a new member to your email list",
"parameters": [
{
"name": "listID",
"in": "path",
"required": true,
"type": "string",
"x-ntx-dynamic-values": {
"operationId": "getLists",
"value-path": "id",
"value-title": "name",
"value-collection": "lists"
}
},
{
"name": "NewMember",
"in": "body",
"schema": {
"type": "object",
"additionalProperties": false,
"required": [ "email_address", "status" ],
"properties": {
"email_address": {
"type": "string",
"x-ntx-summary": "Email address"
},
"status": {
"type": "string",
"x-ntx-summary": "Subscription status",
"enum": [ "subscribed" ]
},
"merge_fields": {
"type": "object",
"properties": {
"FNAME": {
"type": "string",
"x-ntx-summary": "First name"
},
"LNAME": {
"type": "string",
"x-ntx-summary": "Last name"
}
}
}
}
}
}
],
"responses": {
"200": {
"description": "Status 200"
}
}
}
}
},
"securityDefinitions": {
"Basic authentication": {
"type": "basic"
}
}
}
Build the workflow
Build a workflow that:
- Takes prospect applications by a public web form and sends them to the Sales team for qualifying review.
- Adds successful applicants to the company mailing list.
Step 1: Add your Xtension
Import the OpenAPI Specification you created into Nintex Automation Cloud:
- Open your Nintex Automation Cloud tenancy.
- Click Xtensions in the dashboard to open the Xtensions page.
- Click in the Private connector list.
- Click Choose a file. Navigate to the OpenAPI Specification on your computer.
- Wait for Nintex Automation Cloud to validate the file.
- Click Next.
- Nintex Automation Cloud detects the basic authentication security
template.
- Click Next.
- Edit the Name of the Xtension, which becomes the name of the action group in the Workflow designer.
- Edit the Description of the Xtension. This appears in the Private connector list in the Xtensions page.
- Select or upload an icon for the Xtension. This is displayed for each action or event in the Workflow designer.
- Click Publish.
Step 2: Create the workflow
For more information on creating workflows, see the Workflow Designer.
- Click Create workflow in your Nintex Automation Cloud tenancy.
-
Configure the Start event to be a Form with a
file upload for the customer's application, and three text variables:
- The customer's first name.
- The customer's last name .
- The customer's email address.
For more information on designing forms in Nintex Automation Cloud, see Design a form.
- Drag an Assign a task action after the Start event.
For more information, see Assign a task. - Configure the Assign a task action to email the customer's application to the sales team for approval.
- Drag a Send an email action into the Reject branch of the Assign a task
action.
For more information, see Send an email. - Configure the Send an email task to notify unsuccessful prospects using the email address they provided in the form.
- Drag a Mailchimp - Add a new member action to the Approve branch of the Assign a task action.
- Create a new Mailchimp connection using the API key you created earlier:
- Type any text in the Username field.
- Copy your Mailchimp API key in the Password field.
Note: Do not type your Mailchimp account password.
- Use the start form variables to configure the customer's email address, first and last name in the
action.
- Click Test to test the workflow.
- Save or publish the workflow.
Tip: If you want to troubleshoot an Xtension, select Development as the Assigned Use when you publish the workflow. Development workflows display more detailed error messages in their instance details. Republish your workflow as Production when you're ready to use it.