jmeiracorbal/slack-channel-message

Send messages to slack channel

1.2.0 2023-03-05 20:33 UTC

This package is auto-updated.

Last update: 2024-05-06 10:30:44 UTC


README

  • create a Slack app
  • if your app is created, click on your and go to Add features and functionality
  • click on Incoming Webhooks and activate the webhook
  • copy the webhook URL

Send a Slack Message

use SlackChannelMessage\Message;

require_once './vendor/autoload.php';

// change https://hooks.slack.com/services/any_token_slack/generated_token/my_token by yours webhook url
define('SLACK_WEBHOOK_CHANNEL_URL', 'https://hooks.slack.com/services/any_token_slack/generated_token/my_token');

Message::send(
    SLACK_WEBHOOK_CHANNEL_URL, 
    "Send Slack message to our channel"
);

Create message with structures

Messages use structures. Included structures:

  • PlainText
  • Payload: default, like PlainText.
  • Markdown: message content admits makrdown content.

Custom structures

Custom structures must implement StructureSlackMessage. Into get structure you can include the structure. The message returned must be a valid JSON.

Examples