0

I am currently working on coding a simple chat bot application for a slack workspace that I created. I followed a simple tutorial on youtube at the following link: https://www.youtube.com/watch?v=KJ5bFv-IRFM&ab_channel=TechWithTim

Essentially, here are the steps that I followed:

  1. Create workspace
  2. Go to slack api website and click on “Your Apps” in top right hand corner and create app in respective workspace
  3. Add chat:write OAuth Scope for bot token scope
  4. Install to workspace and copy corresponding workspace token
  5. Create two new files in VSCode: bot.py and .env
  6. In .env, add copied slack token into a variable
  7. import libraries, modules, API etc. in bot.py file (code supplied below)
  8. Connect app to "chat-bot" channel

Here is the code for my bot.py file:

import os
from pathlib import Path
from dotenv import load_dotenv # loads environment variable file

env_path = Path('.') / '.env' # tells the system where our environment file is located
load_dotenv(dotenv_path=env_path)

client = slack.WebClient(token=os.environ['SLACK_TOKEN']) # didn't get an autocomplete for WebClient 
client.chat_postMessage(channel='#chat-bot', text="Hello World")

Code to .env file which is in the same directory as my bot.py file:

SLACK_TOKEN= (my slack token that I copied from settings)

The problem arises when I type the client.chat_postMessage(channel='#chat-bot', text="Hello World") line of code. I get an error that tells me that my SSL certificate verify failed. Specifically the error that is generated states: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>

I have already tried a couple of posted solutions such as...

  1. Tried installing /Applications/Python\ 3.9/Install\ Certificates.command but it told me that the requirement is already satisfied
  2. Downgraded webhook to version 0.47.0 as referenced by this post: https://github.com/slackapi/python-slack-sdk/issues/334 I am unable to find anymore solutions to this problem.

If you happen to know what may be causing the issue any insight will be helpful. FYI, I am running the script bot.py using python3 bot.py.

0 Answers0