Learn how easy it is to create an event-driven flow that is triggered by a new message in Slack so that you can perform an action in another app.
Note: This tutorial assumes that you have signed up for free or trial accounts for Slack and MailChimp, or that you have business accounts.
You’re running a successful start-up that hosts popular coding events. Everybody wants to be added as subscribers to your mailing list so that they can be informed when the latest event is running. You’re being bombarded with requests and can’t cope because you never have time to add individuals to your mailing list in MailChimp. You wish they could add themselves to the mailing list! It sounds ridiculous; however, this is possible with App Connect. By using Slack’s New Message action you can create a new flow so that every time a potential attendee writes
/contact followed by their email address in Slack it automatically adds their email address to a MailChimp campaign list. This is great because you also wanted to encourage prospective attendees to sign up to your Slack team and by doing this they can also add themselves to your mailing list without any effort. The attendees are doing your work for you!
If you have already connected Slack and MailChimp to App Connect, the steps to create and test the integration flow in this tutorial should take only a few minutes.
First, find or create everything you need:
- An App Connect subscription (Free or Personal).
- Your team’s Slack URL.
Note: You need to be the owner of a workspace or have admin privileges.
If you need to create a new workspace in Slack to have these privileges, see Create a new workspace and follow the instructions in the link.
- In Mailchimp, create a list, now known in the Mailchimp UI as an audience. Your Mailchimp list (audience) is where you store and manage all of your contacts.
Give your list an appropriate name; for example, “Coding events”.
Next, create your flow:
Using the IBM App Connect Designer authoring experience, you can create your flow from a template, or from scratch if you want to explore the steps taken to create a flow.
Creating the flow from a template
This enables you to create the flow immediately, and then select each node in the flow to validate the node and select the application accounts that you want to use.
Template name: “Add a Mailchimp subscriber from a Slack slash command”
After creating a flow from the template, you can continue to test your flow.
Creating the flow from scratch
This enables you to explore the steps taken to create the flow from scratch, like to create the template.
- Log in to App Connect Designer.
- From the Dashboard, click New > Event-driven flow.
Hint: As you progress, App Connect automatically saves your changes. If you navigate away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.
- Enter a name that identifies the purpose of your flow, for example:
Mailing list sign up
- Select Slack as your first application (source).
- Select New message as the Slack event that will trigger the action in MailChimp.
- If you haven’t already connected a Slack account, click Connect to Slack and follow the instructions to allow App Connect to connect to your Slack account.
- A Callback URL is displayed. Click Copy to clipboard. We need this URL to configure a Slack slash command. The slash command is the trigger for the new message and it will send anything typed after it to the second application we connect in App Connect.
- Open a new browser tab and sign into your Slack workspace.
- Click the arrow next to your workspace name then click Add apps.
- In the Search App Directory field, search for “Slash Commands”.
- Click Install and then Add Configuration.
- In the Choose a Command field, type
/contactand then click Add Slash Command Integration.
- In the Integration Settings section, update the following fields with the following details to create a Slack Slash Command:
- URL: Paste the Callback URL you copied from App Connect earlier.
- Method: POST
- For the purposes of this tutorial, we’ll leave all the other fields with the defaults.
- Click Save Integration.
- Go back to the flow you’re creating in App Connect.
- Click the (+) and then select MailChimp > Add member to a list.
- If you haven’t already connected a MailChimp account, click Connect to MailChimp and follow the instructions to allow App Connect to connect to your MailChimp account.
- In the Lists field, select your list (audience); for example, Coding events list.
- Click inside the Email Address field, then click the Insert a reference icon .
- Select the Message body object from the displayed list of objects. This will map the email address that the attendee types in to Slack (after the slash command) to the email address field in your MailChimp ‘Coding events’ list.
- That’s all for this flow. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow.
Finally, test your flow:
- Go to any channel in your Slack workspace.
- To confirm that the message has been sent, you’ll see a
Message publishedmessage in Slack.
Notice that it is only visible to you. This message will eventually disappear from your thread. As the message is only visible to your users they can be re-assured that nobody else will see their email address.
- Open MailChimp and click Lists > Coding events.
- You’ll see the new addition in the list.
Assign your list to a campaign and the campaign will be sent to all the attendees who have added themselves to your contact list.
If you want to further enhance your experience, install the MailChimp app in Slack so that a notification is displayed in Slack informing you and the attendee that they have been added to the list.