[英]How to reply to a existing message in Microsoft Teams channel via Rest API(incoming webhook)?
I am able to post a message to a team channel using incoming webhook(code sample below).我可以使用传入的 webhook(下面的代码示例)向团队频道发布消息。 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.
我尝试搜索并找到了一些选项,例如团队机器人和微软图形 API。 I wanted to know if there is a straightforward way to do it using incoming webhook or something else before exploring this options.
在探索这个选项之前,我想知道是否有一种直接的方法可以使用传入的 webhook 或其他东西来做到这一点。
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)
I was able to do it via microsoft graph using delegated workflow.我能够使用委派的工作流程通过 microsoft graph 来做到这一点。 Get access on behalf of a user
代表用户获取访问权限
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.