Connect a slack channel to an app

Hi!
I’m developping a slack bot but when I tried to connect my app to the channel,
I get an error with the api.slack

Here is my code:

import slack
import os
from pathlib import Path
from dotenv import load_dotenv
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError


env_path= Path('.') / '.env'
load_dotenv(dotenv_path= env_path)
client = slack.WebClient(token=os.environ['SLACK_TOKEN'])
client.chat_postMessage(channel='#test', text= "Hello world!!")

Could you please help me?

Welcome the community @sam!

Are you sure you are posting in the correct page? Because else I can not understand code which looks like Python.

1 Like