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
You shouldn't link to your site like that, per Community rules. Share your findings here in a Discussion.
Fixed. Thanks.
Great article - followed to a tee and it worked perfectly. Thank you!
Do you need to set up separate webhooks for different forms? Or does this template work for other forms?
We have a number of global forms I would like to feed through to slack:
What code would I enter/how would I set this up so that slack fires for each of these?
You can do it using one webhook only. I am assuming you have different smart campaigns for each form. In that case, just add "{{trigger.Trigger Name}}" token in the payload message instead of "Contact Us Form Submission" text. And then add the other forms in the smart list of the smart campaign. Try this and let me know if that works.
This does work, thank you!
To summarise: you use one catch-all, genericised webhook and have tokens populate the fields on slack in the same way you would an email or LP. Easy peasy!
As an extra flourish, we also added a link to Salesforce so the sales guys could hop into our CRM and check out the new lead (I've erased some of the details). Ideally, we wanted to create a CTA button dynamically populated with a link to the lead's CRM record so our sales guys could navigate straight there. However, the SP_alert_info token wouldn't populate, let alone using the SFDC detail to populate the CTA button. Any ideas why?
As a workaround, we just added a static link to our 'all open leads' page on SFDC, as the majority of our leads tend to be net new.
Try this: https: //na3.salesforce.com/{{lead.SFDC Id:default=edit me}} (remove space between https: and //)in the URL.
Perfect! Thanks for your help - I'm really happy with the result
This is great! Thanks for the write up Gursimran Chandhoke!
Best Always,
Karan Hari
Thanks Karan Hari. You are doing a great job as well with India's first MUG.