All Collections
Method API
Customizing Method to Integrate with Slack
Customizing Method to Integrate with Slack

Using Call Web Service to have Method post to a Slack channel.

Updated over a week ago

Slack is a cloud-based communication tool. In this scenario, we will have Method post information to Slack in a specific channel in real-time by the click of a button.

This is useful in a number of situations, for example, you could customize your Web To Lead form to update a Slack channel when a potential client fills it in.

For this article, we will simply post information about a chosen contact to a channel when a button is pressed to exemplify the process of posting to a slack channel.

In order for this to work, you will need to have the proper permissions in Slack to add apps.

NOTE: This article will assume a strong understanding of Method customization. It will not go into the details of the actions being used.

Configure Slack

  1. Log in to Slack on your browser.

  2. Hover over Your Apps and click Manage your apps (this may look different depending on if you have apps created already).

  3. Click Create an App.

  4. A dialog box will pop up to start creating your app. Click From scratch.

  5. Fill in the App Name and the Slack Workspace you want to integrate and send the messages to. Then select Create App.

  6. The next screen shows your Basic Information. Here, select Incoming Webhooks, either from the left menu or under Add features and functionality.

  7. The next screen is Incoming Webhooks. Toggle it to to On.

  8. Then scroll to the bottom of the same page and select the button at the bottom, Add New Webhook to Workspace.

  9. The next screen gives authorization for this app to post. Select the channel you will have Method post to, and then select the Allow button. In the below example, we are going to post to a channel we created called #method.

  10. You now have a Webhook URL which we will need for later! Copy that!

  11. To verify, you should see a notification in your Slack channel you added an integration to the channel.

Now that you have the Webhook URL, you are set to go into Method to use it!

Use Method's Call Web Service Action

The next part will use Method's Call Web Service Action to send information from Method to the Slack workspace configured above. 

In our example, the Call to Web Service action will be triggered via a button created called Send details to Slack. This button will use the information in the dropdown control which will contain a contact.

NOTE: You may want data to be sent automatically, as opposed to manually triggered by a button. Automatation is beyond the scope of this article, however the process of connecting to Slack via the Call Web Service action is the same.

Controls used in this example

There are two important controls used in this example:

  • ContactDropdown: This is a dropdown control associated to the Contacts table.

  • Send Details to Slack: This is a button control that holds all the actions in its Click event.

Customize the button

  1. Within the Click event of the button, create an Assign Value to Action Result

  2. For Assign the value, I will use the following JSON text below. This is the JSON we will be sending to SLACK. For more information on creating a message in JSON, and what each entry means, please see Slack's article: Incoming Webhooks. (And yes, all of this has to go into that one small text box.)

    "attachments": [
    "title": "A Message from Method",
    "color": "ff0000",
    "text": "This is information on a contact:",
    "mrkdwn_in": [
    "footer": "Method System Bot",
    "footer_icon": "",
    "fields": [
    "title": "Contact Name",
    "value": "Contacts.Name",
    "short": false
    "title": "Contact Email",
    "value": "Contacts.Email",
    "short": false
    "title": "Phone",
    "value": "Contacts.Phone",
    "short": true
  3. For Give it a name, call the action result resultSlackBody .

  4. Add an action to Validate the Controls on Screen for the Contact dropdown control. Ensure you add the validation rule of Field is Required to the Contact dropdown.

  5. Next up, use Merge fields to format the JSON for Slack. You may have noticed the JSON above used merge field notation for the Contacts table. Replace all the instances of Contacts.fieldname with their respective values by adding the Character Functions action.

    • Select a function: Replace Merge Fields

    • Using this text: Use the resultSlackBody we created in the previous step.

    • Merge data from this table: Contacts

    • Using this RecordID: This will be taken from the Contact dropdown.

    • Store result in: Throw the results back in the resultSlackBody action result.

  6. And now we can add the Call Web Service action!

    • Web Service Type: REST

    • Endpoint URL: Enter Webhook URL you created above when configuring Slack.

    • HTTP Method: POST

    • Content Type: application/JSON

    • Parameter Name: Content-Type

    • Value From: Text

    • Value: application/x-www-form-urlencoded

    • Body - Value From:  Action Result resultSlackBody

  7. Your final action set should have four actions and be similar to this:

  8. Close and save the screen.

And that's it! Your web service is set up!

When I press the button and check slack in my #method channel, this is what I see:

Huzzah! Success!

Did this answer your question?