Slack Outbound Example

The following example is an outbound configuration created for Slack.

{
  "$version": "2",
  "api": {
    "base_url": "https://slack.com/api",
    "pagination": {
      "style": {
        "type": "cursor",
        "cursor_query_param": "cursor",
        "limit": {
          "param": "limit",
          "value": 200
        },
        "ordering": {
          "param": "asc",
          "value": ""
        }
      },
      "parser": {
        "next_result_token": {
          "!jq": ".response_metadata.next_cursor"
        }
      }
    }
  },
  "auth": {
    "oauth2_configuration": {
	    "type": "oauth2",
      "configuration": {
        "authorization_base_url": "https://slack.com/oauth/v2/authorize",
        "client_id": "",
        "client_secret": "",
        "scopes": [
          "channels:read",
          "groups:read",
          "chat:write",
          "chat:write.public"
        ],
        "token_url": "https://slack.com/api/oauth.v2.access",
        "refresh_url": "https://slack.com/api/oauth.v2.access?grant_type=refresh_token"
      }
    }
  },
  "workflows": [
    {
      "label": "Post Message to a Slack Channel",
      "description": "Post a message automatically to a Slack channel of your choosing",
      "name": "post-a-message",
      "type": "automations",
      "auth": "oauth2_configuration",
      "setup": {
        "connect": {
          "label": "Connect",
          "describe_connection": {
            "!pipe": [
              {
                "!http": {
                  "method": "POST",
                  "path": "/auth.test"
                }
              },
              {
                "!jq": ".body | {account_id: .user_id, description: (.team + \" Slack Workspace\")}"
              }
            ]
          }
        },
        "select": {
          "label": "Message Settings",
          "form_fields": [
            {
              "label": "Select Channel",
              "id": "channel_id",
              "type": "dropdown",
              "options": {
                "!pipe": [
                  {
                    "!http": {
                      "method": "GET",
                      "path": "/conversations.list",
                      "params": {"types": "public_channel,private_channel" },
                      "pagination": true
                    }
                  },
                  {
                    "!jq": "[.body.channels[] | {display: .name, value: .id}]"
                  }
                ]
              }
            },
            {
              "label": "Enter Message",
              "id": "message",
              "type": "textarea",
              "personalize": "ActiveCampaignContact"
            }
          ]
        }
      },
      "data_pipeline": {
        "source": {
            "!resource": "ActiveCampaignContact"
        },
        "target": {
          "!pipe": [
            {
              "!http": {
                "method": "POST",
                "path": "https://slack.com/api/chat.postMessage",
                "body": {
                  "channel": "${custom_data.channel_id.value}",
                  "text": "${custom_data.message.value}",
                  "username": "ActiveCampaign"
                },
                "headers": {
                  "Content-Type": "application/json"
                }
              }
            }
          ]
        }
      }
    }
  ]
}