I am able to post a message to a team channel using incoming webhook(code sample below). What I am trying to achieve next is to reply to the same message whenever I have a new update. It's just a simple message in reply and need not to be conversational bot. I tried searching and found some options like teams bot and microsoft graph api. I wanted to know if there is a straightforward way to do it using incoming webhook or something else before exploring this options.
import requests
import json
from urllib.request import Request, urlopen, URLError, HTTPError
webhookurl = "https://factset.webhook.office.com/webhookb2/******************"
message = {
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "FF0000",
"summary": "Event Happened",
"sections": [
{
"activityTitle": "Main Title",
"activitySubtitle": "Sub title",
"markdown": True,
"facts": [
{
"name": "Start Time (UTC)",
"value": "2021-06-11 05:48:10"
},
{
"name": "Last Updated Time (UTC)",
"value": "2021-06-11 06:16:15"
}
]
},
}
req = Request(webhookurl, data=json.dumps(message).encode("utf-8"),
headers={"content-type": "application/json"})
try:
response = urlopen(req)
response.read()
except HTTPError as e:
print("Request failed : ", e.code, e.reason)
except URLError as e:
print("Server connection failed: ", e.reason, e.reason)