See Slack and Plumber on R Views for a discussion of this code.
This asset shows how
plumber can be used to build a
Slack slash command. The API is built on
top of a simulated customer
that contains details about customer call history. The slash command provides
access to customer status report as well as customer success rep reports
directly from within Slack. The goal of this integration is to highlight the
plumber and how it can be used to reliably and securely
integrate R with other products and services.
/cs help /cs status <customer_id> /cs rep <rep_name> /cs region <region_name>
Try the following examples using the
/cs command with your
/cs status 10
/cs rep Lovey Torp MD
/cs region east
Simulated data #
|Lovey Torp MD||North||1|
|Miss Halle Heidenreich DVM||East||3|
|Miss Jayne Sanford||West||4|
|Ms. Arely Strosin PhD||…|
|Sannie Schuppe DDS||100|
Instead of registering a different command for each endpoint, the first argument provided to the slash command is the endpoint while the subsequent argument(s) (if necessary) provide additional data to be passed to the specified endpoint. This way, a single slash command serves multiple endpoints without polluting the slash command namespace.
To access a customer status report, enter
/cs status <id> in Slack,
id is a valid customer ID from the simulated data. The customer
status report includes the customer name, total calls, date of birth,
and a plot call totals for the last 20 weeks. The color of the message
is an indication of customer health. Green indicates the customer has no
issues while red indicates the customer has a high volume of calls,
indicating a potential problem.
Help for all available commands can be accessed by entering
/cs into Slack.