An HTTP call can be used to perform an action in your app, or any third-party app through its API.
In this example, we will create an integration, "When a subscriber is created in Mailchimp, post a message to Slack channel" in which HTTP call will be used to send a message to Slack.
- Go to Flows tab from the top menu.
- Create a new flow.
- Select Mailchimp as the source app.
- Select "Subscriber Created" as the trigger.
- Connect your Mailchimp account.
- If you don't have one, you can sign up for free.
- Select the audience you want to monitor for new subscribers and click on Continue.
- Click Test.
- Go to your Mailchimp account and create a subscriber.
- If Integry receives a trigger when you create a subscriber in your Mailchimp account, your test will be successful. Click Done to proceed.
- Select "HTTP Call" as child step. This is where you'll make an HTTP call. You can specify the HTTP method, the URL, parameters, headers, body. You can also specify what authentication to use, more on that below.
- Select an HTTP method. POST method is already selected, keep it unchanged.
- Add the Slack post message endpoint as the request URL.
- Post message endpoint:
https:
//slack.com/api/chat.postMessage
- You can get more info about the endpoint here.
- Post message endpoint:
- In the Authorization tab, select Slack.
- Integry already supports Slack. This means we have already defined how a user of this integration will login/authenticate to give Integry access to their account.
- Integry already supports Slack. This means we have already defined how a user of this integration will login/authenticate to give Integry access to their account.
- Click on the Testing Account dropdown menu and then "+ Add new account" to login to Slack.
- Slack uses OAuth 2.0 so you will see a login screen (if you're not already logged into Slack) followed by a permissions screen to give Integry access to your workspace.
- You have to login so your access token can be used to test the HTTP call to Slack. You can see it's been automatically added under Headers because that's how Slack wants it.
- Once connected, you will see your account listed in Testing Account. If you want to test with another account, you can add it too.
- Slack uses OAuth 2.0 so you will see a login screen (if you're not already logged into Slack) followed by a permissions screen to give Integry access to your workspace.
- In the Parameters tab, you can add URL parameters that will be automatically appended to the request URL.
- Parameters can be static values or dynamic tags.
- Since Slack doesn't require URL parameters, we will skip this step.
- Go to the Body tab. In the code editor, define the body of the post message HTTP call.
- According to their API docs, Slack requires the post message call body to be in JSON in this format:
{ "channel": "YOUR_CHANNEL_ID", "text": "Hello world :tada:"}
- They also require you to specify the content-type in Headers. Once you enter JSON in the code editor, you will notice we add the content-type to Headers automatically.
- According to their API docs, Slack requires the post message call body to be in JSON in this format:
- Enter the conversation (previously known as channels) name where you want to send the message.
- In the text field of your message, you can use dynamic tags to add name, email address, or any value received in the trigger. Here's how:
- Click the + on the top right corner of the code editor.
- Click on Subscriber Created.
- Expand "obj" and then "contact_v1". "contact_v1" is the JSON object received as a trigger.
- Select the email tag if you want to add the subscriber's email address to your message. Expand the custom_fields if you want to use the tags for name, address, phone, etc.
- Click Add to field. A tag for your selected field will be added to your message body. Every time a trigger for a new subscriber is received, their email address will be dynamically inserted into the message body in place of the tag.
- Complete your message body.
- Click Test. If your call is successful, you'll receive a message in your selected conversation.
- Publish the integration to your marketplace.
When your users set up this integration, they need to connect their Mailchimp account and map the list of contacts in their audience. For Slack, they will only need to connect their account to authorize Integry to perform an action. The Slack channel configuration is pre-set during integration creation via an HTTP call.
Comments
0 comments
Please sign in to leave a comment.