如何从其他应用程序向 Microsoft 团队发布消息 [英] How do I post a message to Microsoft team from other application

查看:55
本文介绍了如何从其他应用程序向 Microsoft 团队发布消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的桌面应用程序中创建一个自定义方法(使用 C#),以便向 Microsoft 团队发布消息.但我仍然不知道使用什么样的工具或服务来完成它.有可能实现吗?如果是,如何?

我在 Visual Studio 中发现了一个关于 MS-Teams 的金块.但它不会工作.就像在 Visual Studio 市场一样.我发现的是

  • 安装/配置 webhook,通过提供 webhook 名称.点击创建
    • 它会为你创建一个链接,复制链接

    1. 最后一步,在 Power shell 中使用此命令行

    curl.exe -H "Content-Type:application/json";-d "{'text':'服务器 x 已启动.'}";https://example.webhook.office.com/webhookb2/4dee1c26-036c-4bd2-af75-eb1abd901d18@3c69a296-d747-4ef3-9cc5-e94ee78db030/IncomingWebhook/87557542b42d8d3b04453c4a606f2b92/b852b3d0-84b6-4d98-a547-ae5f53452235

    注意:命令行中的 URL 包含一些伪造的 guid 编号,但您需要将其替换为您从 webhooks 中获取的那个.

    您可以在 power shell 中调用此行,也可以将其合并到 c# 中.

    现在,当我运行命令时,我在该频道中收到一条消息:


    如果您需要删除已添加的挂钩,请单击已配置,然后单击配置.并管理 webhook:并删除

    I am trying to make a custom method in my desktop application (using C#), to post a message into a Microsoft team. but I still don't know what kind of tool or services to get it done. is it possible to achieve it? if yes, how?

    I found a nugget regarding MS-Teams in Visual Studio. but it won't work. as in Visual studio market place. what I found is https://marketplace.visualstudio.com/items?itemName=ms-vsts.vss-services-teams

    But it seems like doesn't meet my requirement.

    解决方案

    You can follow 3 steps to send message notifications to your channels:

    1. In your teams, right click on your channel. And send for Incoming webhook.
    2. Install/configure webhook, by provide a webhook name. Click on Create

    • It will create you a link, copy the link

    1. Last step, use this command line in Power shell

    curl.exe -H "Content-Type:application/json" -d "{'text':'Servers x is started.'}" https://example.webhook.office.com/webhookb2/4dee1c26-036c-4bd2-af75-eb1abd901d18@3c69a296-d747-4ef3-9cc5-e94ee78db030/IncomingWebhook/87557542b42d8d3b04453c4a606f2b92/b852b3d0-84b6-4d98-a547-ae5f53452235
    

    Note: the URL in the command line contains some faked guid numbers, but you need to replace it with the one you get from webhooks.

    You can either call this line in power shell or incorporated in c#.

    Now when I run the command I get a message in that channel:


    In case you need to remove hook that you have added, click on Configured then Configure. And Manage the the webhook: And remove

    这篇关于如何从其他应用程序向 Microsoft 团队发布消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆