---
url: 'https://metadrop.net/en/articles/how-to-develop-a-pomodoro-application-for-slack-in-php'
title: 'How to develop a Pomodoro application for Slack in PHP'
author: 'Eduardo Morales'
date: '2020-12-13T15:58:14+00:00'
updated: '2026-08-04T07:53:36+00:00'
type: article
summary: 'Slack has a very wide API to pull from. In this article, you will learn in a simple way in a few steps how to code a Pomodoro application based on PHP without having too much knowledge about the technologies involved.'
tags:
  - PHP
image: 'https://metadrop.net/sites/default/files/styles/full/public/imce/image/article/slack.jpg.webp?itok=HWrHVywP'
published: true
og:
  determiner: Automatic
  site_name: Metadrop
  'image:url': 'https://metadrop.net/sites/default/files/styles/full/public/imce/image/article/slack.jpg.webp?itok=HWrHVywP'
  'image:type': image/jpeg
  'image:width': '810'
  'image:height': '456'
  'image:alt': 'How to develop a Pomodoro application for Slack in PHP'
  street_address: 'Calle Manuel Luna, 12, 3 Dcha'
  locality: Madrid
  region: Madrid
  postal_code: '28020'
  country_name: España
  email: hola@metadrop.net
  phone_number: '910053180'
schema:
  '@context': 'https://schema.org'
  '@graph':
    -
      '@type': Article
      '@id': 'https://metadrop.net/en/articles/how-to-develop-a-pomodoro-application-for-slack-in-php#article'
      name: 'How to develop a Pomodoro application for Slack in PHP'
      headline: 'How to develop a Pomodoro application for Slack in PHP'
      description: "Slack has a very wide API to pull from. In this article, you will learn in a simple way in a few steps how to code\_a Pomodoro application based on PHP without having too much knowledge about the technologies involved."
      about: PHP
      image:
        '@type': ImageObject
        url: 'https://metadrop.net/sites/default/files/styles/full/public/imce/image/article/slack.jpg.webp?itok=HWrHVywP'
        width: '810'
        height: '456'
      datePublished: '2020-12-16T16:58:14+0100'
      dateModified: '2026-08-04T09:53:36+0200'
      author:
        '@type': Person
        name: 'Eduardo Morales'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
      mainEntityOfPage: 'https://metadrop.net/en/articles/how-to-develop-a-pomodoro-application-for-slack-in-php'
    -
      '@type': Organization
      '@id': 'https://metadrop.net/#organization'
      url: 'https://metadrop.net/'
      name: Metadrop
      sameAs:
        - 'https://www.drupal.org/metadrop'
        - 'https://twitter.com/metadrop'
        - 'https://asociaciondrupal.es/partner/metadrop'
        - 'https://www.linkedin.com/company/metadrop'
      logo:
        '@type': ImageObject
        url: 'https://metadrop.net/themes/custom/mdrop_radix/logo-metadrop-500-500.jpg'
        width: '500'
        height: '500'
    -
      '@type': ItemPage
      '@id': 'https://metadrop.net/en/articles/how-to-develop-a-pomodoro-application-for-slack-in-php'
      breadcrumb:
        '@type': BreadcrumbList
        itemListElement:
          -
            '@type': ListItem
            position: 1
            name: Home
            item: 'https://metadrop.net/en'
          -
            '@type': ListItem
            position: 2
            name: 'Expert Drupal & Tech Articles'
            item: 'https://metadrop.net/en/articles'
      publisher:
        '@type': Organization
        '@id': 'https://metadrop.net/#organization'
---
 1. [Articles](https://metadrop.net/en/articles)
 
  

# How to develop a Pomodoro application for Slack in PHP

Wednesday, December 16, 2020

 

 



Slack has a very wide API to pull from. In this article, you will learn in a simple way in a few steps how to code a Pomodoro application based on PHP without having too much knowledge about the technologies involved.



   



## Introduction

Slack is one of the most common tools for professional communication and allows integration with multiple applications or plug-ins. An example would be Google Calendar, which allows you to configure it to show the closest meetings in the application itself. Therefore Slack can be considered one of the most important tools for the organisation of a team if it is used in a responsible way.

## Introducing the Slack API

Slack has very good [documentation of its API](https://api.slack.com/ "Api slack"), as well as a large community of developers using its application, so if you don't find something or have questions accessing the official Slack website documentation, then you can find it on development forums such as [Stack Overflow](https://stackoverflow.com/questions/tagged/slack "Stack Overflow Slack").

## The PHP library

Although we could develop the integration with the Slack API completely from scratch, it is not efficient to reinvent the wheel, as the aim of the article is to have a functional application in a few steps and in a simple way.

Having said that, I introduce you to the library that we are going to use: [jolincode/slack-php-api](https://github.com/jolicode/slack-php-api "Slack PHP API"). It is a Composer's library, so we are going to import it into the project using this package management system. It also has quite a few [slack methods](https://github.com/jolicode/slack-php-api/blob/master/generated/Client.php "Available Slack methods") that can be useful and which are updated periodically.

## Cookbook

Ingredients:

- [Composer](https://getcomposer.org/download/ "Install Composer")
- [Php](https://www.php.net/manual/en/install.php "PHP instalation")
- Have a Slack workspace to test

Steps:

- Create a new folder where the project will be located.
- Run `composer init` to be able to import the libraries needed for this project.
- Import the libraries as described in the [Slack library installation manual](https://github.com/jolicode/slack-php-api#installation "Slack installation API")

Your composer will look something like this:

```bash
... 
   "require": {
        "symfony/http-client": "^5.2",
        "nyholm/psr7": "^1.3",
        "jolicode/slack-php-api": "^3.0",
    }
```

- Copy this snippet into a file `pomodoro.php` in the root of the project. For example:

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use JoliCode\Slack\ClientFactory;
use JoliCode\Slack\Exception\SlackErrorResponse;

// Slack Token.
$user_token = 'xoxp-XXXX-XXXX-XXXX-XXXX';
$client = new ClientFactory($user_token);
try {
  $status = [
    // Status message.
    "status_text" => 'Pomodoro time!!',
    // Status icon.
    "status_emoji" => ':tomato:',
    // Status duration.
    "status_expiration" => strtotime('+25 minutes'),
  ];
  $status_json = json_encode($status);
  $result = $client->usersProfileSet([
    "profile" => $status_json,
  ]);

  echo 'Status updated.' . PHP_EOL;
} catch (SlackErrorResponse $e) {
  echo 'Failure.', PHP_EOL, $e->getMessage() . PHP_EOL;
}
```

- Replace the example "**user\_token**" 'xoxp-XXXX-XXXX-XXXX-XXXX' with the one generated in the next step (get the user token).

## Get a user token in Slack

These are the steps to obtain the token of the user currently registered in Slack, so it will not be possible to overwrite the status of other users by following these steps.

- Go to [the Slack API](https://api.slack.com/ "API de Slack") with you slack user and then go to [**"Your apps"**](https://api.slack.com/apps "Your apps")
- Create a new application by clicking on the button "**Create New App**"
- After creating the application, go to a "**Features/OAuth &amp; Permissions**" on the left sidebar.
- Go to "**User Token Scopes**" and add the permission "`users.profile:write`" click the button "**Add an OAuth Scope**". This permission is what will allow the application to overwrite the user status.
- Select "**Settings/Install App**" and choose a workspace to install the application.
- After installing the application you will get an "**OAuth Access Token**" that will be something like:
    
    ```plaintext
    xoxp-XXXX-XXXX-XXXX-XXXX
    ```

## Execute the PHP script

If you already have PHP installed on your computer, remember to add the Slack token to the previous PHP snippet in order to update the profile.

All you have to do is run the script from a Bash console.

```bash
bash$ php /SCRIPT_DIRECTORY/pomodoro.php
```

You will see that your profile status has been updated, both the message and the icon temporarily if everything went well.

## Conclusions

Now that you know about the Slack library, I invite you to try different methods, for example, sending a message to a specific channel. You can also try to create a bot, although you will need to have a server where it is hosted.

Remember that depending on the methods you use you will have to grant specific permissions to the application and you will have to reinstall it in the workspace. For example, [if I go to the method for sending a message in the chat](https://api.slack.com/methods/chat.postMessage "Method for sending a slack message.") we will see that the scope required for the user is `chat:write`.

## Potential improvements

You have learned to change your profile status in Slack, but the Slack application also allows you to do certain actions under certain commands that you type in the chat called slash commands, with that you could create a command so in the case of writing `/pomodoro start` for example, change the profile status.

## Original project

You can see the original project on which this article was based at [Github with the name slack\_pomodoro.](https://github.com/Eduardo-Morales-Alberti/slack_pomodoro "Slack Pomodoro PHP")

## Other projects

- [Slack Cli Bash](https://github.com/rockymadden/slack-cli "Slack bash library")
- [Slack Cli Python](https://pypi.org/project/slack-cli/ "Slack Cli Python")



[PHP](https://metadrop.net/en/articles?text=PHP)

 

- Eduardo Morales
    
    Senior Drupal developer
 
[Module development and third-party integrations with Drupal](https://metadrop.net/en/services/drupal/integrations " See Module development and third-party integrations with Drupal")

Metadrop connects Drupal to your CRM, ERP, payment, and marketing stack — Salesforce, Microsoft Dynamics, BBVA virtual POS, Workday, and Keepeek — with custom modules and secure, GDPR-compliant APIs.

 

 See more