<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/slack-and-plumber-part-one/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rviews.rstudio.com/2018/08/30/slack-and-plumber-part-one/"> R Views</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In <a rel="nofollow" href="https://rviews.rstudio.com/2018/07/23/rest-apis-and-plumber/" target="_blank">the previous post</a>, we introduced <a rel="nofollow" href="https://www.rplumber.io/" target="_blank"><code>plumber</code></a> as a way to expose R processes and programs to external systems via REST API endpoints. In this post, we'll go further by building out an API that powers a <a rel="nofollow" href="https://api.slack.com/slash-commands" target="_blank">Slack slash command</a>, all from within R using <code>plumber</code>. A subsequent post will outline deploying and securing the API.</p>
<div>
<img src="https://i0.wp.com/rviews.rstudio.com/post/2018-08-15-blair-plumber-slack-files/slash-command-preview.png?w=456&ssl=1" data-recalc-dims="1">
</div>
<p>We will create an API built on top of simulated customer call data that powers a slash command. This command will allows users to view a customer status report within Slack. As shown, this status report contains customer name, total calls, date of birth, and a plot of call history for the past 20 weeks. The simulated data, along with the script used to create it, can be found in the <a rel="nofollow" href="https://github.com/sol-eng/plumber-slack" target="_blank">GitHub repository</a> for this example.</p>
<div>
<h2>Setup</h2>
<p><a rel="nofollow" href="https://slack.com/" target="_blank">Slack</a> is a commonly used communication tool that's highly customizable through various integrations. It's even possible to build your own integrations, which is what we'll be doing here. In order to build a Slack app, you need to have a Slack account and follow <a rel="nofollow" href="https://api.slack.com/slack-apps" target="_blank">the instructions for creating an app</a>. In this example, we will build an app that includes a slash command that users can access by typing <code>/</code></div>