DEV Community

Cover image for WorkDash - Slack Status Changer
Dídac
Dídac

Posted on

2 1

WorkDash - Slack Status Changer

The other day I decided that I will build something for my desk and I did this:

My idea is to make kind of a cheap DIY version of Elgato Stream Deck and the first version only uses the Slack's API to change my status, but it's a start.

For now, if you are interested to build your own you can check the gist that I've made to make one for yourself:

#include <ArduinoJson.h>
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "your-wifi-name";
const char* password = "your-wifi-password";
const char* slackToken = "Bearer your-slack-app-token";
const char* serverName = "https://slack.com/api/users.profile.set";
const int PushButton = 34;
void setup() {
Serial.begin(115200);
pinMode(PushButton, INPUT);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
int button_state = digitalRead(PushButton);
if ( button_state == HIGH ) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
http.begin(serverName);
http.addHeader("Host", "slack.com");
http.addHeader("Content-Type", "application/json; charset=utf-8");
http.addHeader("Authorization", slackToken);
DynamicJsonDocument doc(1024);
JsonObject profile = doc.createNestedObject("profile");
profile["status_text"] = "Lunch time!";
profile["status_emoji"] = ":sandwich:";
String requestBody;
serializeJson(doc, requestBody);
int httpResponseCode = http.POST(requestBody);
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
Serial.println("Slack status updated to Lunch time!");
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
}
}

Follow this series to known what else I will be adding!

--

Nice banner from Banner build by Liyas Thomas 🦄

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more