1

Context: I work at a small MSP and I've created a bot that direct messages employees when one of their tickets goes overdue. The message has a few buttons that allow the user to request an extension on the ticket. Once a button is clicked, our ticketing system's API is used to update the ticket and the chat message updates to reflect the selected update.

What I'd like to do after one of the request extension buttons is clicked is to ask the user if they would like to add a note to the ticket. If Yes button is clicked, the bot would prompt the user to respond with a note to add.

Here's my question. Is there any way to read the next message from the user after they click yes? As in, should the user click 'Yes' to add a note, can I trigger a script to run when the next user message is posted?

For what it's worth, I'm writing this in PHP. I'm using chat.postMessage to post the message when a ticket goes overdue, and simply "replacing" the message with a new one using that message's responseURL when a button is clicked.

Any Slack API gurus out there with any ideas?

Graham Bewley
  • 195
  • 3
  • 13

1 Answers1

2

Well.. if I understand your problem correctly, there is a much easier approach:

The buttons automatically call your script and tell you what the user clicked. So you can respond appropriately. Its all part of the Interactive Message feature in the Slack api. And you can configure which url Slack should call in the Slack App config window. Check out the offical documentation for Interactive Buttons more info.

However, I guess what you really want is the ability for the user to enter some free text, like in a html form input field. That is currently not possible in Slack, but that very feature is promised on the current Slack API roadmap to be delivered in the near future. Its called "Interactive message Stage 3".

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • I understand that, I'm currently using interactive messaging to receive input from the buttons and request extensions on tickets. What I'm asking is if there is a way for a user to send a custom message and have the bot read the message and use it's text for something, in this case for adding a note to a ticket. – Graham Bewley Aug 19 '17 at 23:33
  • 1
    you can use a bot user that your user can send a message to directly with @botname. You can then use the [Event API](https://api.slack.com/events-api) to receive and repond to those messages. – Erik Kalkoken Aug 20 '17 at 00:00