- a. Create the channel that you want to notify.
- b.
App
-Search: webhook
-Incoming Webhook
https://teams.microsoft.com/l/app/203a1e2c-26cc-47ca-83ae-be98f960b6b2?source=app-details-dialog - c. Click
Request Approval
After you can use webhook incomming. Proceed to next steps. Microsoft Teams allows limited application access per organization, so it can only be used if the webhook incoming application is available. - c. Go to the team channel to receive notifications, and click
Connectors
in Settings. - d.
Connectors
After configuring webhook incoming in Connector, copy the webhook URL.
API TEST
from ExceptNotifier import send_teams_msg
_TEAMS_WEBHOOK_URL = 'xxxx'
send_teams_msg(_TEAMS_WEBHOOK_URL, "Any Test Message")
Notifier
import sys
from ExceptNotifier import ExceptTeams, SuccessTeams, SendTeams
sys.excepthook = ExceptTeams.__call__
# Define the next two variables optionally when using OpenAI's API.
# os.environ['_OPEN_AI_MODEL']="gpt-3.5-turbo"
# os.environ['_OPEN_AI_API']="sk-xxxxxx"
os.environ['_TEAMS_WEBHOOK_URL'] = 'microsoft webhook _TEAMS_WEBHOOK_URL'
try:
print(1/20)
SuccessTeams().__call__() #1 success sender
except ExceptTeams as e: #2 except sender
sys.exit()
SendTeams().__call__() #3 customized sender