إعداد إشعارات Microsoft Teams باستخدام إضافة discourse-chat-integration

يصف هذا الدليل كيفية إعداد موفر Microsoft Teams المضمن في discourse-chat-integration.

إعداد Microsoft Teams

في Microsoft Teams:

  1. من شريط التنقل العمودي على اليسار، انقر فوق زر النقاط الثلاث (\u003ckbd\u003e…\u003c/kbd\u003e) وحدد \u003ckbd\u003eWorkflows\u003c/kbd\u003e (سير العمل) من القائمة.

  2. انقر فوق الزر \u003ckbd\u003e**+ Build from scratch**\u003c/kbd\u003e (إنشاء من الصفر) في الزاوية العلوية اليمنى من صفحة Workflows (سير العمل).

  3. في نافذة سير العمل المخصص المنبثقة، ابحث عن webhook وحدد المشغل When a Teams webhook request is received (عندما يتم استلام طلب خطاف ويب Teams).

  4. في حقل Who can trigger the flow (من يمكنه تشغيل التدفق)، حدد Anyone (أي شخص). [1]

  5. انقر فوق \u003ckbd\u003e**+ New step**\u003c/kbd\u003e (خطوة جديدة).

  6. بعد ذلك، ابحث عن card (بطاقة) وحدد الإجراء Post card in a chat or channel (نشر بطاقة في محادثة أو قناة).

  7. املأ الحقول كما يلي:

  • Post as: (النشر بصفتك:) اختر من يجب أن تأتي الرسائل منه؛ يمكنك ترك هذه القيمة مضبوطة على القيمة الافتراضية أو اختيار User (مستخدم) لجعل الرسالة تظهر منك.

  • Post in: (النشر في:) حدد Channel (قناة)، مما سيؤدي إلى ظهور المزيد من الحقول:

    • Team: (الفريق:) حدد الفريق المطلوب.
    • Channel: (القناة:) حدد القناة المطلوبة.
    • Adaptive Card: (بطاقة تكيفية:) انقر داخل الإدخال، مما سيفتح نافذة منبثقة (موضحة في الخطوة التالية).

  1. انقر داخل حقل Adaptive Card (البطاقة التكيفية) لفتح نافذة منبثقة [2] لإدراج محتوى ديناميكي أو تعبير. قم بالتبديل إلى علامة التبويب Expression (التعبير) واكتب triggerBody() في حقل التعبير.

  2. انقر فوق \u003ckbd\u003eSave\u003c/kbd\u003e (حفظ).

  3. يجب أن ترى الآن سير عمل يسمى manual → Post card in a chat or channel في قائمتك. انقر فوق زر النقاط العمودية على سير العمل هذا وحدد \u003ckbd\u003eDetails\u003c/kbd\u003e (التفاصيل) من القائمة المنسدلة.

  4. في هذه الصفحة، انقر فوق \u003ckbd\u003eCopy webhook link\u003c/kbd\u003e (نسخ رابط خطاف الويب) للحصول على الرابط للخطوات التالية. بينما أنت هنا، يمكنك اختياريًا تعديل اسم سير العمل ليعكس الغرض منه للآخرين في فريقك.

إعداد Discourse

الآن، نعود إلى Discourse:

  1. في منطقة مسؤول Discourse، قم بتمكين الإعداد Chat integration enabled (تم تمكين تكامل الدردشة) لتشغيل مكون الإضافة Chat Integration وتمكين الإعداد Chat integration Teams enabled لدعم Microsoft Teams.

  2. في الشريط الجانبي، ابحث عن قسم Plugins (المكونات الإضافية) وانقر فوق Chat Integrations (تكاملات الدردشة)، ثم انقر فوق \u003ckbd\u003e**+ Create Channel**\u003c/kbd\u003e (إنشاء قناة).

  3. في نافذة Edit Channel (تحرير القناة) المنبثقة، املأ الحقول كما يلي:

  • Name: (الاسم:) أدخل اسمًا يوضح القناة التي تتصل بها في Microsoft Teams؛ لا يلزم أن يكون مطابقًا تمامًا.
  • Webhook URL: (عنوان URL لخطاف الويب:) الصق عنوان URL لخطاف الويب الذي نسخته في الخطوة 11 من قسم إعداد Teams أعلاه.
  1. انقر فوق \u003ckbd\u003eSave Channel\u003c/kbd\u003e (حفظ القناة).

اختبار التكامل

حان الوقت للتأكد من أن كل شيء يعمل كما هو متوقع.

  1. في Discourse، انقر فوق \u003ckbd\u003eTest\u003c/kbd\u003e (اختبار) على القناة التي تم إنشاؤها حديثًا.

  2. ابحث عن موضوع حسب المعرف أو العنوان أو عنوان URL؛ حدد الموضوع المطلوب؛ وانقر فوق \u003ckbd\u003eSend Test Message\u003c/kbd\u003e (إرسال رسالة اختبار).

  3. في Microsoft Teams، يجب نشر رسالة جديدة تحتوي على معلومات من الموضوع في القناة:

اختياري: إعداد قواعد لقناتك

بمجرد التأكد من أن كل شيء يعمل، يمكنك العودة إلى Discourse وإعداد قواعد إضافية لقناتك لتخصيص الرسالة.

استكشاف الأخطاء وإصلاحها

إذا لم تظهر الرسالة في Microsoft Teams كما هو متوقع، فانتقل إلى صفحة Workflow Details (تفاصيل سير العمل) (راجع الخطوة 10 في قسم إعداد Teams أعلاه) وتحقق من قسم Run history (سجل التشغيل). يجب أن يعرض هذا سجلات لكل عملية تشغيل للرسالة.

انقر فوق التشغيل الفاشل، والذي سينقلك إلى منطقة Power Automate حيث يمكنك رؤية رسالة خطأ في الجزء العلوي من الصفحة. (في لقطة الشاشة أدناه، كان التشغيل ناجحًا، لكن السهم يشير إلى المكان الذي سيظهر فيه الخطأ في حالة فشل التشغيل.)

يجب أن يوضح هذا المشكلة، والتي يمكنك بعد ذلك إصلاحها أو مشاركتها معنا هنا حتى نتمكن من المساعدة.


    1. لا يدعم Discourse حاليًا خطافات الويب المصادق عليها إلى Teams، لذا فإن خيار “Anyone” (أي شخص) فقط هو الذي يعمل.
    ↩︎
  1. إذا لم تظهر النافذة المنبثقة، اكتب أي شيء مؤقتًا في حقل البطاقة التكيفية، واحفظ سير العمل، وافتحه مرة أخرى للتحرير، ويجب أن تظهر النافذة المنبثقة. ↩︎

12 إعجابًا

Just tried it out and it seemed to work at first, but only the first time I clicked on the test button.
Rules are set up as follows:

  • Type: normal
  • Filter: All topics(?) and replies (translating from German here)
  • Category: Sandbox

When I wrote a reply to the test topic in my Sandbox category I got a warning sign when I went to my chat integrations, but when clicking on the warning triangle it says unknown error... with the error message bein null.

When I try to send another test notification it gives me another error 500 internal server error

Any hints on where to start trouble shooting this are welcome. If this should be posted elsewhere (e.g. under the chat integration plugin page), or made a separate topic, feel free to move it accordingly or let me know.

3 إعجابات

Hi @SHilser - please can you check /logs on your site, and see if there is anything relevant there?

إعجابَين (2)

There’s two things that seem relevant.

  • Socket Error
  • Internal Server Error

I copied the logs below (I replaced my domain name with mydomain.tld)

Socket Errror

Message (4 copies reported)

SocketError (Failed to open TCP connection to outlook.office.com:443 (getaddrinfo: Temporary failure in name resolution))
app/controllers/application_controller.rb:340:in `block in with_resolved_locale'
app/controllers/application_controller.rb:340:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:68:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:336:in `call'
config/initializers/100-quiet_logger.rb:19:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:22:in `call'
lib/middleware/request_tracker.rb:176:in `call'

Backtrace

/usr/local/lib/ruby/2.6.0/net/http.rb:949:in `rescue in block in connect'
/usr/local/lib/ruby/2.6.0/net/http.rb:946:in `block in connect'
/usr/local/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/usr/local/lib/ruby/2.6.0/timeout.rb:103:in `timeout'
/usr/local/lib/ruby/2.6.0/net/http.rb:945:in `connect'
/usr/local/lib/ruby/2.6.0/net/http.rb:930:in `do_start'
/usr/local/lib/ruby/2.6.0/net/http.rb:919:in `start'
/usr/local/lib/ruby/2.6.0/net/http.rb:1470:in `request'
rack-mini-profiler (2.0.4) lib/patches/net_patches.rb:19:in `block in request_with_mini_profiler'
rack-mini-profiler (2.0.4) lib/mini_profiler/profiling_methods.rb:33:in `step'

Env

HTTP HOSTS: mysite.tld

Internal Server Error

Message (4 copies reported)

Error: Internal Server Error
Url: https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js
Line: 1
Column: 267890
Window Location: https://mysite.tld/admin/plugins/chat/teams

Backtrace

o/t</<@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:267890
o/t<@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:267993
o@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:268074
trigger@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:545343
A</e._onError/<@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:550189
f</t.invoke@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:490190
f</t.flush@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:489198
p</t.flush@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:491205
t</t._end@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:496596Here
t</t.end@https://mysite.tld/assets/ember_jquery-1ed3f3559e6f967733b4088aa729ff7039dff2c09c5a5f787a214b016f58aabc.js:1:493157

Env

HTTP HOSTS: mysite.tld

Thanks for the help :slight_smile:

إعجابَين (2)

That suggests that your server is having trouble with DNS resolution. Are you using a standard docker-based installation? Or is this in development?

3 إعجابات

Just set it up about a week ago on a separate DigitalOcean droplet (one-click installation, now I’m on Version: 2.6.0.beta1 (310952fd6a). I use a subdomain and have the DNS records also on DigitalOcean. I have an A-Record, pointing to the IP, MX-Record pointing to the sub-domain name for reply by email as per these instruction). Only thing there is that I don’t have a DMARC Record published.

That’s all I can think of that I did in relation to DNS stuff. However, so far everything worked as expected. The site is set up, I can reach it via the sub-domain name, log-in, create topics (even via email), etc.

I’m just startled the first message made it through, but subsequent ones didn’t :man_shrugging:

إعجابَين (2)

When I say DNS resolution, I mean your server is having trouble contacting outlook.office.com. The setup of your forum’s DNS records shouldn’t affect that.

Can you try connecting to your server via SSH and running

host outlook.office.com

You should get something like

outlook.office.com is an alias for substrate.office.com.
substrate.office.com is an alias for substrate.ms-acdc.office.com.
substrate.ms-acdc.office.com is an alias for afd-k.office.com.
afd-k.office.com is an alias for outlook-office-com.k-0002.k-msedge.net.
outlook-office-com.k-0002.k-msedge.net is an alias for k-0002.k-msedge.net.
k-0002.k-msedge.net has address 13.107.18.11
k-0002.k-msedge.net has IPv6 address 2620:1ec:c::11
3 إعجابات

When I enter

host -d outlook.office.com

I get the following:

Trying "outlook.office.com"
Host outlook.office.com not found: 2(SERVFAIL)
Received 36 bytes from 127.0.0.53#53 in 43 ms

When adding port :443 I get another error

Trying "outlook.office.com:443"
Host outlook.office.com:443 not found: 3(NXDOMAIN)
Received 40 bytes from 127.0.0.53#53 in 3 ms
Received 40 bytes from 127.0.0.53#53 in 3 ms

For other domains like google.com or the domain of my discourse instance in question (h-da.transformative-praxis.cc), or other sites I get the expected output similar to what you describe.

I did some search for the first error, but I’m still not sure about its source. I’ve read the following, but wasn’t able to judge, if this is actually relevant to my problem:

إعجاب واحد (1)

I kept retrying it and this time I got the results you described when typing

host outlook.office.com

So everything seemed fine at this point. I’ve repeated that many times in a row to make sure (like around 15 times with an interval of around 10 seconds) and at some point I got the same servfail error as before. But mostly it worked.

The opposite is the case when I try to send a test message. It maybe works one out of ten times. The other times I get the same errors as before. And when I post a regular message that fits to the rule I’ve set for the channel, I don’t get a notification, nor an error message in the logs.
It just seems so random to me that I can’t find out what causes it.

I kept suspecting my setup with two droplets for each subdomain and two respective A-Records, plus one set of NS-records for my main domain pointing to ns1.digitalocean.com. So I tried out dnsstuff for my site getting a Fail for the SOA record check and whatsmydns.net for my NS records, but I still couldn’t figure out any possible connections to my problem.

At this point I’m totally confused who’s causing the error, me having made some wrong DNS settings (which shouldn’t affect it according to @david), server settings/issues, or is it just MS-Teams (outlook.office.com) acting up, or blocking me in some way?

Any hints for what I could check/do to find the error are appreciated, including where else to go and ask, if you think this is beyond what you can do to help me here.

Thanks a lot for all the help so far.

إعجاب واحد (1)

Hi, thanks for this. I keep failing at step Discourse 5: The dialogue box says my incoming Webhooks URL is invalid?

Any help appreciated!

Dan

إعجاب واحد (1)

Would you mind sharing what your webhook URL looks like? Either via PM to me or, if you can invalidate it first, here in the topic?

إعجاب واحد (1)

Thanks @Dan_Turner, I just relaxed our validation a little which should help the situation. Please give it a try and let me know if it works better for you

https://github.com/discourse/discourse-chat-integration/commit/00ec1f486a3fd1dc523cdf242cfb1c78baaa407e

إعجابَين (2)

Thanks! Will give it a try.

Dan

إعجاب واحد (1)

Sorry to be thick but do I need to update Discourse or edit the file directly as detailed in the fix?
Thanks, Dan

إعجاب واحد (1)

You need to update the plugin. Visit /admin/upgrade, and press the update button next to “Discourse-chat-integration”

إعجابَين (2)

Hey - so sorry for being incompetent but - how do I actually try this as I’m on a hosted discourse instance? Thanks. Dan

إعجاب واحد (1)

You will need to ask your hosting provider to update the plugin for you. At discourse.org this change has already gone out to all our customers, so I guess you must be hosted elsewhere?

إعجاب واحد (1)

yeah, discourse hosting for me. which version is it in please and I will ask them to update?

إعجاب واحد (1)

We don’t have version numbers for plugins, but you can share this commit link with them: https://github.com/discourse/discourse-chat-integration/commit/00ec1f486a3fd1dc523cdf242cfb1c78baaa407e

إعجابَين (2)

شكراً لك على هذه الإضافة المفيدة للغاية.
سيكون التحسين الكبير هو: إضافة إشارة للمجموعة في الرسالة لتوليد إشعارات على جانب Teams.
يبدو أن واجهة برمجة تطبيقات webhook لم تكن (أو لا تزال) تطبق هذه الميزة، ولكن البعض يقول إنها تم تطبيقها مؤخرًا.
هل تعتقد أنه يمكن تطبيقها بسهولة؟