Files
taro-bot-python/app.py
Björn Benouarets ee9903b704 init: Initial commit
2026-01-19 14:14:54 +01:00

26 lines
1.1 KiB
Python

from bot.msteams.auth import Auth
from bot.msteams.conversation import Conversation
from bot.msteams.adaptivecard.webhook_card import WebhookCard
from bot.msteams.adaptivecard.template import Template
import os
MS_TEAMS_APP_ID = os.getenv("MS_TEAMS_APP_ID")
MS_TEAMS_APP_PASSWORD = os.getenv("MS_TEAMS_APP_PASSWORD")
MS_TEAMS_TENANT_ID = os.getenv("MS_TEAMS_TENANT_ID")
TEAMS_ID = os.getenv("TEAMS_ID")
CHANNEL_ID = os.getenv("CHANNEL_ID")
if not MS_TEAMS_APP_ID or not MS_TEAMS_APP_PASSWORD or not MS_TEAMS_TENANT_ID or not TEAMS_ID or not CHANNEL_ID:
raise ValueError("Missing environment variables")
auth = Auth(MS_TEAMS_APP_ID, MS_TEAMS_APP_PASSWORD, MS_TEAMS_TENANT_ID)
conversation = Conversation(auth)
template = Template("webhook-card")
card = WebhookCard(data={
"creator.name": "SecNex",
"creator.url": "https://avatars.githubusercontent.com/u/155033045?s=200&v=4",
"content": "This is a webhook card.",
"action.title": "Show more",
"action.url": "https://secnex.io"
}, template=template)
print(conversation.new_conversation_with_card(CHANNEL_ID, card))