top of page
Recent Posts
Writer's pictureMunshi Hafizul Haque

How to create a new workspace and setup a Slack Webhook for Sending Messages From Applications

As we know, slack is the collaboration hub that brings the right people, information, and tools together to get work done. In other word, Slack will be a platform or workspaces where teams can cultivate conversation, inspire action, and integrate services by building apps or workflows. Let's start with Slack.


Create a new workspace:

Step:1 We can create a brand-new work-space for me and my team at https://slack.com/intl/en-my/get-started#/.


Click the "Create A Slack Workspace" button from the Web Page, as below.

Enter my email and verify the security code to create the slack workspace, as below.

After the successful configuration, it will looks like as below.

OK, good to go for the next steps.


Create a slack Webhook:

Step:1 Click Apps Tab from my slack workspace.

Step:2 Search the "Incoming Webhooks" and click Add, as below.


Step:3 Click Add to Slack, as below.

Step:4 Select the channel Name, as below.

Step:5 Save the webhook URL that will look like as below:

https://hooks.slack.com/services/ABCDEFGHI/ZXCVBNMAS/AbCdEfGhJiKlOpRQwErTyUiO

Step:6 Save the webhook URL that will look like as below:

# curl -X POST --data-urlencode "payload={\"channel\": \"#ansible\", \"username\": \"webhookbot\", \"text\": \"This is posted to #ansible and comes from a bot named webhookbot.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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
ok

Will result in my slack workspace :

Another example, Message with Attachment, Error:

 # curl -X POST -d 'payload={"channel": "#ansible", "username": "webhookbot", "text": "*Incoming Alert!*", "icon_emoji": ":bort:", "attachments":[{"fallback":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>","pretext":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>","color":"#D00000","fields":[{"title":"Notes","value":"This is much easier than I thought it would be.","short":false}]}]}}' https://hooks.slack.com/services/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
ok 

Will result in my slack workspace :

Another example, Message with Attachment, OK:

 # curl -XPOST -d 'payload={"channel": "#ansible", "username": "webhookbot", "text": "*Status Update:*", "icon_emoji": ":borat:", "attachments":[{"fallback":"New open task has been closed [OK]: <http://url_to_task|Test out Slack message attachments>","pretext":"Task has been closed [OK]: <http://url_to_task|Test out Slack message attachments>","color":"#28B463","fields":[{"title":"Notes","value":"The error has been resolved and the status is OK","short":false}]}]}}' https://hooks.slack.com/services/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

Will result in my slack workspace:


Resources:

  • https://api.slack.com/docs/message-attachments




53 views0 comments

Comments


Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page