Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

slack chat.postMessage vs. incoming webhook?

I am trying to send messages from several outer sources to a specific channel, which is private and belongs to myself only. The username should be the name of source, not my ID.

I found there are two ways to do such a similar function: Incoming Webhooks and chat.postMessage

I have already practiced these two, which seems no difference between them.

However, in Incoming Webhooks, a statement says:

You can't use Incoming Webhooks with Workspace Apps right now; those apps can request single channel write access and then use chat.postMessage in the Web API to post messages, providing very similar functionality to Incoming Webhooks.

What does it mean?

To my work, which one is better?

like image 664
ShanChe Wu Avatar asked Apr 29 '19 02:04

ShanChe Wu


People also ask

What is incoming webhook Slack?

Incoming webhooks allow you to add context to your messages by attaching helpful content and links. Things like images, websites or other pieces of data make these messages more useful for your team. If you'd like a member of our support team to respond to you, please send a message to [email protected].

Is Slack webhook deprecated?

Slack incoming webhooks have been deprecated for a while. We have been able to migrate all of our webhooks away to dedicated Slack apps instead, and also created a private Slack app for our own internal webhook needs.

What is incoming and outgoing webhooks?

Incoming webhooks allow an external system to add content to a discussion thread. Outgoing webhooks allow an external system to react to a message that has been posted in a discussion thread.

What is an incoming webhook?

An Incoming Webhook lets external applications to share content in Microsoft Teams channels. The webhooks are used as tools to track and notify. The webhooks provide a unique URL, to send a JSON payload with a message in card format.


2 Answers

Adding to what Ben said:

Incoming webhooks are limited in their functionality. They are great if you need an easy way to send a message that does not require a token, but in general the API method (chat.postMessage) is the better choice. It is more flexible (e.g. not fixed to one channel) and provides the full functionality (e.g. you get the ID for a message and can later update it).

Workspace apps / tokens where a new functionality that allowed apps to be installed in one channel only (among other things). It never left its beta stage and can be safely ignore for further development.

like image 93
Erik Kalkoken Avatar answered Oct 11 '22 05:10

Erik Kalkoken


with chat.postMessage() you send a message to a specific channel, often you do that in response to a users action. You will need the token to verify the postMessage Request which you receive when the user installs your app. Incoming webhooks are often used to post general information, e.g. patch notes or general announcements. As far as I know, you don't need the token since there is a verification behind that Url. so the webhook url is bound to a specific channel, which is specified through the user. With chat.postMessage you can post messages anywhere (depending on your permissions, maybe not in private channels or direct messages)

like image 7
Ben Denger Avatar answered Oct 11 '22 04:10

Ben Denger