Search code examples
ralertslackslackr

Error in if (nrow(chan) == 0) { : argument is of length zero in slackr Package


I am currently trying to create a slack - R integration to create an alert when specific rules / threshold is hit. I'm using slackr package (v. 2.1.0)

The only function that is working right now is only slackr::slackr_bot as it successfully send a bot message into the private channels.

start <- paste0("Start checking the anomaly")
slackr::slackr_bot(start, incoming_webhook_url=whurl )

and it return a slack notifications below: slack notifications successfully sent

When I am trying to set the initial slackr_setup with below command (I believe it is needed for more functions like sending image, post) it keep getting error. Below are the script used:

slackr::slackr_setup(channel = "test_slack_alert_mn", 
                    username = '@Alert System',
                    icon_emoji = "",
                    incoming_webhook_url = whurl, #variable from slack app
                    bot_user_oauth_token  = apitk, #oauth_token from slack app
                    echo = FALSE
                    )

This is the error message:

Error in if (nrow(chan) == 0) { : argument is of length zero

Do you guys know what happen here and what should I do to solve this?

Thank you in advance!


Solution

  • Unfortunately I'm experiencing the same issue.

    I can add that this is a problem that appeared very recently.

    A Shiny App I developed months ago relies on slackr & gmailR to send notifications to the admin.

    It started to fail on the slackr_setup with exactly the same error Error in if (nrow(chan) == 0) { on last deployment a few days ago.

    I just fixed it by installing the latest dev version on github !

    devtools::install_github("mrkaye97/slackr")

    I think the fix came from this commit where if(nrow(chan)==0) was replaced by if(is.null(chan)||nrow(chan)==0)