Note from Community Moderator added 2021-03-08: the webhook payload described here will break when any of several common characters appear in Lead/Person/Company fields. For updated guidance on creating properly escaped JSON payloads, see an upcoming post on the Products Blog. |
In March 2019, I got a chance to go to Adobe Sumit in Las Vegas. This was my first time attending the Summit. It’s fascinating to meet several experienced Marketo folks and learn from them One of the Marketo Champions introduced me to Webhooks. So I thought, why not learn webhooks by integrating Marketo and Slack. Go easy on me; I consider this my first real article.
Integrating Marketo and Slack
Marketo webhooks are great way to send/receive data with the third-party service. It is done using GET or POST HTTP method (learn more about HTTP methods). In this article, we will show how to send the data from Marketo to Slack using webhooks. For example, when someone fills a particular form (eg. contact us form), then the lead/contact information is sent to Slack. This is really useful if you want to share the lead/contact information with someone who doesn't have access to Marketo instance.
Requirements:
1. Marketo account with admin access
2. Slack account
Terminologies:
1. Incoming webhooks - This is a URL that will receive the data from the third-party. In our example, Slack's incoming webhook URL will receive the data from Marketo.
2. JSON Payload - This is the JSON data (learn more) that is sent using POST method. In our example, this is lead/contact information who fills contact-us form that will be sent from Marketo to Slack. The syntax of the payload is as follows:
{"text": "Your message will go here. This can also include tokens, etc."}
Step-by-Step Instructions:
Sending the information of lead/contact who fills a contact us form from Marketo to Slack can be achieved using 3 simple steps.
Step 1: Setup Incoming Webhook in Slack
First step is to configure incoming webhook in Slack so that Slack can receive the data from Marketo. To do so:
1. To create a incoming webhook in Slack, create a new app by going to https://api.slack.com/apps.
2. Click on "Create New App" and enter the app name (eg. Marketo) and select the workspace. Click on "Create App".
3. Click on "Incoming Webhooks" and activate them using toggle button.
4. Click on "Add New Webhook to Workspace" and select the channel/direct message and click on authorize.
5. It will generate an incoming webhook URL. Save that URL somewhere. We will need it later.
Step 2: Send Payload Template from Marketo
For sending payload template, we need to create Marketo webhooks.
1. Open Marketo and go to Admin -> Webhooks. Click "New Webhook" to create a Marketo webhook.
2. Enter the name (eg. "Slack Integration - Test") and description.
3. In the URL, enter the incoming webhook URL that we created earlier.
4. Select Request Type as "POST" and Response Type as "JSON".
5. In the template, enter the payload as below.
{"text": "Contact Us Form Submission \n First Name: {{Lead.First Name}} \nLast Name: {{Lead.Last Name}} \nEmail: {{Lead.Email Address}} \nCompany: {{company.Company Name:default=not entered}} \nMessage:{{Lead.Message:default=not entered}}."}
6. Your webhook will look like this.
7. Click Save.
That's it. You have created your first Marketo webhook.
Step 3: Create a trigger campaign
Tip: Marketo webhooks only works with Trigger campaigns
Trigger campaign is required that will listen for Contact-us form fill trigger and then send the information to Slack by calling the webhook.
1. Create a new Smart Campaign.
2. In the smart list, select "Fills-out form" trigger and select Contact-us form.
3. In the flow step, select "Call Webhook" and select the appropriate webhook ("Slack Integration Test" in this case).
4. Activate the smart campaign.
That's it. Now all the leads/contacts who will fill Contact-us form, you can see their information in Slack. You will see the message in Slack like shown below.
Resources