Data source: Slack


Slack is a collaborative communication service, enabling users to exchange information either through ad-hoc communications or within communication channels.

It is possible to send messages within a communication channel, to notify users in an automated way.

If you have correctly configured the Slack connection parameters, Temma automatically creates an object of type \Temma\Datasources\Slack, with which you can send notifications. By convention, we'll assume that you've named this connection slack in the etc/temma.php file (see configuration documentation).

In the controllers, the Slack connection is then available by writing:


In other objects managed by the dependency injection component, the Pushover connection is accessible by writing:



To send notifications on Slack, you must first install the Incoming Webhook application (official application designed by Slack) in your Slack organization, then retrieve the provided Incoming Webhook URL.

In the etc/temma.php file (see configuration documentation), you declare the DSN (Data Source Name) used to connect to Slack.

The DSN used to connect to Slack can be written in several ways:

  • slack://WEBHOOK
  • slack://AUTHOR@WEBHOOK

Avec :

  • WEBHOOK the value of the Incoming Webhook URL retrieved, without the https:// prefix.
  • AUTHOR the name to be displayed as the notification sender.
  • ICON the URL to the image to be used as avatar by the notification sender.

3Notification content

Notifications can contain text, which accepts a derivative of Markdown syntax.

Notifications can also have "attachments", i.e. blocks that can themselves contain text, an image, "footer" text, text that is positioned above the block, as well as an author name, which can be a clickable link and/or include an avatar image.

4Unified calls

4.1Array-like access

// send a simple notification
$this->slack['CHANNEL'] = "Message to send";
// with CHANNEL, which corresponds to the name of the channel you wish to
// send the message (with the pound sign at the beginning)

// send a formatted notification
$this->slack['CHANNEL'] = [
    'text'        => 'Text of the notification, with <|a link>',
    'attachments' => [
            'pretext' => 'Text above the block',
            'author'  => 'Name of the author of the block',
            'icon'    => 'Block author icon URL',
            'link'    => "URL of the link on the author's name",
            'text'    => "*bold* _italic_ ~strikedout~ `code`",
            'image'   => "",
            'footer'  => "Text of the block footer",
        'Text block',
        "Another text-only block",
            'image' => "",

4.2Advanced method

// send a simple notification
$this->slack->set('CHANNEL', "Message to send");

// send a formatted notification
$this->slack->set('CHANNEL', [
    'text'        => 'Main text',
    'attachments' => [
        'First block',
        'Second block',

// sends a notification, specifying the author's name and icon
$this->slack->set('CHANNEL', "Message", [
    'author' => "Author's name",
    'icon'   => "",

5Specific calls


// definition of the author's name and icon,
// to be used for all subsequent mailings
$this->slack->setAuthor("Author's name", '');