I'm trying to create a bot response to slack using Plumber and I can get the model to work and get a text response when querying from the command line or testing from swagger. When I use a slash command from Slack though the response comes back but there is only an empty response displayed in the channel. I've tried a number of small tweaks but it just won't do it for me so hoping someone who has a working Slack Plumber bot can see what I'm doing wrong.
#' return chatbot response
#' @param text the message used for analysis
#' @post /response
function(text=" ", res) {
# turn parsed message into tidy dataframe
msg_df <- tibble(line = 1:1, text = text)
# unnest words in dataframe and create response
msg_df <<- msg_df %>% unnest_tokens(word, text)
body <- pred(msg_df)
my_message <- list(response_type = unbox("in_channel"),
text=unbox(body))
return(my_message)
}
and this is what I get back from slack once its dockerised and run.
the response coming back looks like this which is what I see in Slack tutorials
Response body
{
"response_type": "in_channel",
"text": "some text information"
}
Really appreciate any ideas!
An initial solution is that the Plumber serializer can be chaged to:
@serializer contentType list(type="text/plain") #provides a simple text response
This works if all you need is plain text without formatting (which works in my case)