markwragg / Powershell-SlackBot

Powershell based Slack Bot using the Real Time Messaging API and WebSockets.
http://wragg.io/powershell-slack-bot-using-the-real-time-messaging-api/
46 stars 19 forks source link

Invoke-slackbot -Token not working: Error Below #11

Closed AdminTurnedDevOps closed 4 years ago

AdminTurnedDevOps commented 6 years ago

Hello,

Currently getting the following error when I try to run Invoke-SlackBot -Token $Token

PS C:\Windows\system32> Invoke-SlackBot -Token $Token
Set-PSSlackConfig : The term 'Set-PSSlackConfig' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\SlackBot\1.0.59\Public\Invoke-SlackBot.ps1:10 char:5
+     Set-PSSlackConfig -Path $PSSlackConfigPath -Token $Token
+     ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-PSSlackConfig:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

VERBOSE: I am 
Exception calling "ConnectAsync" with "2" argument(s): "Value cannot be null.
Parameter name: uri"
At C:\Program Files\WindowsPowerShell\Modules\SlackBot\1.0.59\Public\Invoke-SlackBot.ps1:21 char:13
+             $Conn = $WS.ConnectAsync($RTMSession.URL, $CT)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

I've tried the following; 1) Removing the module 2) Re-installing the module with the -force param 3) Single quotes and double quotes around my token 4) Tried client ID, Client Secret, and Verification Token from Slack (I know it's only the token, but I wanted to try it and see if I would get a different error). 5) Tried in ISE running as admin and VSCode

Tried again with -Verbose and got the following: VERBOSE: GET https://slack.com/api/rtm.start?token=tokennumber with 0-byte payload VERBOSE: received -1-byte response of content type application/json; charset=utf-8 VERBOSE: Creating C:\SlackConfig\log.txt. VERBOSE: I am VERBOSE: Closing websocket

Any ideas?

markwragg commented 6 years ago

Sorry, this is because its assuming you would also have the PSSlack module installed, which it can use as another way to send messages in to slack. You can get it here: https://github.com/RamblingCookieMonster/PSSlack

I should probably make that optional.

AdminTurnedDevOps commented 6 years ago

No worries! Thank you. I see that module may compliment your module well. Maybe in the instructions you can put in that the PSSlack module is required as well. Thanks for the assistance :).

AdminTurnedDevOps commented 6 years ago

Still getting this error unfortunately:

VERBOSE: I am 
Exception calling "ConnectAsync" with "2" argument(s): "Value cannot be null.
Parameter name: uri"
At C:\Program Files\WindowsPowerShell\Modules\SlackBot\1.0.59\Public\Invoke-SlackBot.ps1:21 char:13
+             $Conn = $WS.ConnectAsync($RTMSession.URL, $CT)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

I tried the verification token, client token, and Client ID to confirm. Single quotes, double quotes, and no quotes around the tokens. Variable to hold the tokens and no variable. For some reason it's still coming up as null. I distributed the app/bot to confirm it was live.