SDriver: a Delphi wrapper for Slack API
SDriver: a Delphi wrapper for Slack API
Slack (slack.com) is a popular communication platform that can be used to improve collaboration in teams. It provides services like instant messaging and document sharing across a group of people in public or private way.
You can freely setup your own organization (team) and create some channels (eventually assigning members to specific channels) for discussion. The official help center provides you a fair documentation of their features.
Out of the box, Slack provides you a web app client (with a subdomain dedicated to your organization, mine is https://andreamagni.slack.com ) as well as native apps for the most common platforms out there (Windows, Mac OSX, Linux, Android, iOS…).
Having a way to programmatically send messages into a channel or to a specific member obviously is a very nice add on for every integrated system, just to name an advantage think about the fact the (human) members can receive realtime notifications when somebody (human or not) send a message into a channel or to the member himself.
Each member has a stateful view of the messages so one can always know those messages has been already read and those that has not (avoiding to force people to always look at the message queue).
Last but not least, Slack provides a long list of integrations with other systems and tools. Just to name one I really love, Trello has a very good integration with Slack (and viceversa).
Incoming Webhooks
Incoming webhooks are a way to interact with the Slack environment from the outside. For example, you may want to send a message into a channel or to some specific members so they get notified or have a chance to take action to respond at some event.
Using SDriver you can send messages to a Slack WebHook from your application server, your mobile app, a desktop software or some command line utility you may want to build for example to use it in a script or batch file.
Once you have setup the webhook in the Slack settings of your organization, a URL will be available to send data to the Slack system. This is the key configuration item you need to use SDriver to send messages from your software.
Message attachments
Sending a simple text message is already fine but what if you want to provide a more structured content to Slack? Message attachments are the answer to the question and SDriver provides you to define them within your message.
For example, once a order is placed on an e-commerce website, a message can be sent to a Slack group of users to notify them a new order is ready to be processed. As attachments the system can provides some details of the order (for example, the list of items ordered and their specific quantity and options), some informations about the customer (recent orders, support tickets, contact info and so on) or some internal informations (for example current availability of ordered items).
Custom slash commands
If incoming webhooks are a way to send data to Slack from the outside, you may want to cause some action from Slack to the outside world. If you are familiar with most popular messaging systems for sure you already have seen commands into chats (like “/kick ” and similar). Think about having a way to let a team member write a command in a channel or in his own private chat and have an effect outside of the Slack environment (like receiving an http POST on some URL of yours). That’s it!
You may want to build a Delphi REST server using any technology/library available, I will provide an example using MARS-Curiosity very soon.
A real world example
I am going to use SDriver in a real world project of one of my customers where there are several software instances running an e-commerce website, some system integration with third party software processes and a client server backend. All made with Delphi (using different technologies) so a very nice chance to test integration with Slack to ease internal communication for the company.
You can freely setup your own organization (team) and create some channels (eventually assigning members to specific channels) for discussion. The official help center provides you a fair documentation of their features.
Out of the box, Slack provides you a web app client (with a subdomain dedicated to your organization, mine is https://andreamagni.slack.com ) as well as native apps for the most common platforms out there (Windows, Mac OSX, Linux, Android, iOS…).
Having a way to programmatically send messages into a channel or to a specific member obviously is a very nice add on for every integrated system, just to name an advantage think about the fact the (human) members can receive realtime notifications when somebody (human or not) send a message into a channel or to the member himself.
Each member has a stateful view of the messages so one can always know those messages has been already read and those that has not (avoiding to force people to always look at the message queue).
Last but not least, Slack provides a long list of integrations with other systems and tools. Just to name one I really love, Trello has a very good integration with Slack (and viceversa).
Incoming Webhooks
Incoming webhooks are a way to interact with the Slack environment from the outside. For example, you may want to send a message into a channel or to some specific members so they get notified or have a chance to take action to respond at some event.
Using SDriver you can send messages to a Slack WebHook from your application server, your mobile app, a desktop software or some command line utility you may want to build for example to use it in a script or batch file.
Once you have setup the webhook in the Slack settings of your organization, a URL will be available to send data to the Slack system. This is the key configuration item you need to use SDriver to send messages from your software.
Message attachments
Sending a simple text message is already fine but what if you want to provide a more structured content to Slack? Message attachments are the answer to the question and SDriver provides you to define them within your message.
For example, once a order is placed on an e-commerce website, a message can be sent to a Slack group of users to notify them a new order is ready to be processed. As attachments the system can provides some details of the order (for example, the list of items ordered and their specific quantity and options), some informations about the customer (recent orders, support tickets, contact info and so on) or some internal informations (for example current availability of ordered items).
Custom slash commands
If incoming webhooks are a way to send data to Slack from the outside, you may want to cause some action from Slack to the outside world. If you are familiar with most popular messaging systems for sure you already have seen commands into chats (like “/kick ” and similar). Think about having a way to let a team member write a command in a channel or in his own private chat and have an effect outside of the Slack environment (like receiving an http POST on some URL of yours). That’s it!
You may want to build a Delphi REST server using any technology/library available, I will provide an example using MARS-Curiosity very soon.
A real world example
I am going to use SDriver in a real world project of one of my customers where there are several software instances running an e-commerce website, some system integration with third party software processes and a client server backend. All made with Delphi (using different technologies) so a very nice chance to test integration with Slack to ease internal communication for the company.
What’s next
In the next few weeks I plan to:
improve the Incoming Webhooks demo
add a demo to show Message Attachments
add a simple server implementation of a Slash command
wrap Message buttons
investigate some more API available to wrap