Search code examples
botsslack-apislack

Slack bot to pre-format channel responses of structured data input from user


At work we have a Slack channel where each person posts their daily scrum updates. The format is something like this:

Yesterday:

 - Did something
 - Did something else

Today:

 - Did something
 - Did something else

Blocks:

 - This is blocking my progress

Now, I'm trying to find a way in which I can have this preformatted for my colleagues i.e. like placeholder text in HTML

enter image description here

Is there a way to achieve this in Slack?

The options I have considered so far are as seen here 1. Create a / command on Slack that would respond with this text when a user types /daily and populate the response (I'm not sure about the feasibility of this, I have only created slash commands that triggered an external process, not returned any text to Slack) 2. Create a custom application and integrate with Slack

I realize that the answer to this can be opinionated, and that that is discouraged in the community, but I'm thinking others might also have come across this issue or will, in the future, and the answer is relatively objective here, not purely subjective.


Solution

  • I have been developing a several Slack apps and came across similar requirements. Slack does currently not offer good options for entering structured data in my opinion, so I would recommend to rather use a HTML page with a simple form for entering the data which then automatically posts the update on Slack.

    Options with pure Slack

    You can use slash commands or a bot to receive the input from your user, but in both cases the user has to enter data command line style and is it not possible to use something like HTML placeholders. Your options are either to use keywords or to have a conversation between the user and the bot. The input is free text and will need to be parsed by your app.

    Example for slash commands with keywords:

    /daily yesterday "this and that" 
    /daily today "this and that" 
    /daily blocks "this and that"
    

    Example for a bot conversation:

    @scrumbot daily
    "What is your update for yesterday?"
    @scrumbot this and that
    "What is your update for today"
    @scrumbot this and that
    etc.
    

    I have been using both approached in my apps, but they are pretty clumsy and not very user friendly for entering larger amount of structured text.

    Slack with HTML page

    My recommendation would therefor be to rather use a simple HTML form to enter the text and then automatically post the result in the Slack channel. You can either use Sign-in with Slack or let the user click a generated link on Slack to connect a generated HTML page to the correct Slash user. The first offers better security, the later is more user-friendly.

    Example:

    /daily
    "Please click *here* to enter your daily update"
    

    Then a generated HTML page opens in the browser which allows the user to enter his data in a form. After submit the input is posted on Slack in the correct channel

    Btw. the Slack team is planning to implement input field for Slack in the future, but this is currently scheduled for mid term, so I would not expect it to be available in the near future. See "Interactive messages Stage 3" on the Slack Plattform Roadmap.

    Update September 2017

    The Slack team have introduced a new method to enable users to enter structured data called dialogs.

    Dialogs are similar to forms in HTML and allow to create modal dialog windows with multiple input field of various types (currently text, textarea, select) within Slack. They can be triggered as response to a slash command or an interactive message (buttons, menus).

    The new dialog feature would now be the best choice to get structured input from the user like requested in this question.