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

Unfortunately neither of those things are possible at the moment.

إعجابَين (2)

Hello there, I am currently setting this up, and I am not sure if the interface changed or not, but are these scopes setup under Bot Token Scopes or under User Token Scopes?

Thank you.

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

Both of these things should be possible using Zapier integration. Less than ideal, I know, but since I’ve been looking at it as a workaround for this plugin I thought I’d share.

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

Hi there!

I tried to configure the plugin as explained in this thread but when I try to post a transcript I only get from the slack bot:

“Loading the transcript…”

My Discourse is hosted in the “discourse.group” subdomain. This is what I get from the error logs:

/var/www/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/slack/slack_command_controller.rb:86:in `block in process_post_request’

/var/www/discourse/lib/scheduler/defer.rb:94:in `block in do_work’

rails_multisite-2.1.0/lib/rails_multisite/connection_management.rb:252:in `with_connection’

rails_multisite-2.1.0/lib/rails_multisite/connection_management.rb:61:in `with_connection’

/var/www/discourse/lib/scheduler/defer.rb:89:in `do_work’

/var/www/discourse/lib/scheduler/defer.rb:79:in `block (2 levels) in start_thread’

Do you know how to fix this?

Where the error is occurring indicates the Slack credentials entered on your site settings page are not correct. To find your Chat Integrations settings, go to your Admin / Settings page and scroll to the bottom of the left-side menu. You will see a “Chat Integrations” button at the bottom of the list.

On that settings page, make sure that the following settings are correct:

  • chat integration discourse username
  • chat integration slack access token
  • chat integration slack incoming webhook token

Let us know if that doesn’t solve the issue. Since your site is hosted by us, we can have a look at what is going wrong.

إعجابَين (2)

Solution for Errors:

1) DiscourseChat::ProviderError

2) {\"ok\":false,\"error\":\"not_in_channel\"}

Trying to make this more obvious because it was unfortunately difficult to find the answer. The Slack App creation process has changed a bit since these instructions. And it seems the actual integration of the bot with a channel in Slack takes a bit more setup as well.

From my Slack workspace, I could confirm the app was working by DM’ing the bot @discourse as well as the running commands /discourse. But from the Discourse Plugin settings, I was receiving errors and could not set a channel nor send a test message.

How to implement

EDIT: there is updated information in the replies below. I’ve attempted to incorporate the additional steps here as of 4/6/20. Please comment or modify these as needed. - dp

  1. Bot permissions: chat:write.customize permission needs to be added in order for the /discourse post slash command to work. I also added chat:write.
  2. You’ll need to create the channel in Slack. And then either run the /discourse commands from the channel or set up a rule in Discourse.
  3. You need to manually add the bot to the channel of interest (at least to post a transcript)! You can do this in the private conversation with the bot in slack: "conversation settings" > "add this app to a channel".
  4. Then, importantly, you need to add the discourse bot user to the channel. I could not get this to work through the normal channel “add user” or “add app” buttons. BUT I was successful by sending a message to “@discourse” within the channel → I was then prompted by slack with the message “@discourse is not in this channel, would you like to add?”
  5. I could then run a test message successfully from Plugins settings :rocket:

Note: in the Slack app setup I set the App name to @discourse

5 إعجابات

Thanks @thedavidprice and @simon for your great support!

I’ve fixed the issue! Everything was fine but the bot needed to be added to the channel to post a transcript. Maybe you can add this point to the list of instructions above?

Another thing I noticed is that the chat:write:bot permission scope is not available anymore, you have to chose chat:write!

4 إعجابات

Hi @Vincenzo_Lomonaco, to confirm, you are saying the Plugin itself will now add the bot to the channel (for example, when creating a rule)?

Indeed, it seems a lot has changed on the Slack setup side of things. I can confirm I added chat:write. I also added chat:write.customize.

Once created via Slack API, it wasn’t clear to me if I needed to also add the app to a channel within my Workspace settings for Apps. In my case I did chose a channel.

Lastly, I also had some confusion about whether or not I needed to add “Display Information” on the app settings page of Slack. I did, which seems to be the information used within Slack app directory and for “Recent Apps” in Slack left column. My image url I entered within Discourse for the bot messages does not seem to be working. The name of the bot is working.

Thanks again! Overall very happy with how things are going.

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

Hi @thedavidprice,

No, you need to manually add the bot to the channel of interest (at least to post a transcript)! You can do this in the private conversation with the bot in slack: "conversation settings" > "add this app to a channel".

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

Thanks for doing this. I have updated the guide based on your post and my own testing. I can confirm that the chat:write.customize permission needs to be added to the Bot Token Scopes setting in order for the /discourse post slash command to work.

I thought that the channels:join scope might be all that is needed to allow the bot to automatically join a channel, but based on my testing this does not work. I think the easiest way to add the bot to a channel is now outlined in step 15 of the guide. If there is a better way to do it, please let me know.

I’ll clean up the replies in this topic in a few days, once we have confirmed that the current state of the guide is working for people.

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

مرحبًا يا أصدقاء، أبحث عن إعداد هذا التطبيق لمكان يتمتع بقيود أمان أكثر صرامة. عند مراجعة النطاقات المطلوبة الموثقة في المنشور الأصلي مقارنة بما هو مسموح به حاليًا، هذا ما أراه:

chat:write # ؟ غير واضح، لكن chat:write:bot مقبول
chat:write.customize ؟ غير واضح، لكن chat:write:bot مقبول
users:read X مرفوض
channels:history X مرفوض
groups:history # مقبول، مقبول بحذر
im:history # مقبول، مقبول

إذا تم إعداد التطبيق فقط بالنطاقات التالية، فما الذي سيعمل وما الذي سيتعطل؟

chat:write:bot
groups:history
im:history

على سبيل المثال، لا بأس بي بالتخلي عن المحادثات المسجلة…

3 إعجابات

مرر وقت طويل منذ أن قمت بتنفيذ هذا لأول مرة، ويبدو أن نطاقات Slack قد تغيرت كثيرًا منذ ذلك الحين. أرى أن الناس يحافظون على تحديث ويكي المنشأ الأصلي، وهذا رائع! :heart_eyes:

أعتقد أن chat:write:bot و chat:write:user تم إيقافهما لصالح chat:write.

يبدو أن chat:write.customize مطلوب لأننا نخصص اسم المؤلف وأيقونة المؤلف للرسالة لتطابق مستخدم Discourse.

تُستخدم نطاقات users:read و *:history فقط لنشر النصوص المنقولة. أدرك أن هذا قد يبدو كثيرًا! ولكن في الأساس، يحتاج Discourse إلى الوصول إلى سجل محادثاتك لبناء النص المنقول. إذا فضلت عدم منح هذه الأذونات، فلا بأس بتخطيها تمامًا والاستمرار دون نشر النصوص المنقولة.

3 إعجابات

عند استخدام أوامر الشرطة المائلة، أواجه هذه الرسالة: /hub فشلت مع رسالة الخطأ "dispatch_failed"

(نستخدم /hub بدلاً من /discourse)

تمكّنت من إضافة التطبيق إلى القناة. كما تمكّنت من إرسال منشور تجريبي من Discourse إلى Slack الخاص بنا، لكنني لم أستطع فهم كيفية عمل أوامر /. أود الحصول على مساعدة في استكشاف المشكلة وحلها!

هل يمكنك التحقق من الأذونات التي أضفتها للتطبيق على Slack؟ آخر مرة حاولت فيها إعداد هذا، كانت جميع الأذونات من الخطوتين 5 و6 من الدليل مطلوبة لإضافتها إلى نطاقات التطبيقات:

  • chat:write
  • chat:write.customize
  • users:read
  • channels:history
  • groups:history
  • im:history

أخبرنا إذا لم يحل ذلك المشكلة.

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

أعتقد أن لدي الأذونات الصحيحة. إليك لقطة شاشة للإعدادات التي أملكها تحت نطاقات رمز البوت.

ما رأيك؟ للأسف، هذا يعني أن هناك شيئًا آخر يحدث.

إعجابَين (2)

لقد راجعت دليل الإعداد مرة أخرى وأنشأت أمرًا قصيرًا /hub. يعمل استدعاء /hub post بالنسبة لي في أي قنوات أضفت التطبيق إليها. أنا أستخدم نفس الأذونات الموجودة في لقطة الشاشة التي نشرتها.

هل يمكنك التأكد من إتمامك الخطوة 8 من الدليل؟ تخبرك تلك القسم بما يلي:

انتقل إلى صفحة التفاعلات والاختصارات، فعّل قسم التفاعلات عن طريق تحويله إلى تشغيل وأدخل عنوان URL هذا تحت عنوان “عنوان URL المطلوب”:

<your-discourse-url>/chat-integration/slack/interactive

قد يكون من الجيد أيضًا التأكد من قدرتك على النشر من منصة Discourse إلى قناة Slack التي تحاول تشغيل أمر /hub post عليها.

أخبرنا إذا لم تتمكن بعد من جعل هذا يعمل.

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

لقد تحققت وأعتقد نعم، لقد اتبعت تلك الخطوة.

إليك لقطة شاشة.

أعتقد أن الخطأ يحدث في شيء متعلق بالخطوة 7، على الرغم من ذلك.

إليك إعداداتي.

هذا ما يظهر عندما أحاول استخدام أمر السلاش في Slack:

نعم، هذا الجزء يعمل بشكل مثالي.

لا، لا يعمل. :slightly_smiling_face:

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

عنوان “URL” المطلوب في قسم “تحرير الأمر” من لقطة الشاشة الخاصة بك لا يستخدم HTTPS. ربما تكون هذه هي المشكلة.

إعجابَين (2)

نجح الأمر، شكرًا لك!!!

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

لقد اتبعت التعليمات الواردة في هذا الدليل، وأصبحت تكامل Discourse/Slack الخاص بي يعمل (إلى حد كبير). عمل رائع مع هذا الملحق! لدي ثلاث أسئلة/ملاحظات.

لا يمكن الاشتراك في الرسائل في فئة فرعية عن طريق الاشتراك في الفئة الأصلية

قد يكون هذا مقصودًا بالتصميم، لكنه لم يكن واضحًا في البداية. لدي فئات أصلية تحتوي على فئات فرعية تحتها. توقعت أنه إذا أنشأت قاعدة تصفّر “جميع المنشورات والردود” إلى الفئة الأصلية، فستشمل ضمناً كل فئة فرعية أيضًا. لكن يبدو أن هذا لم يعمل، واضطررت إلى إنشاء قواعد لكل فئة فرعية (الكثير منها). سيكون هذا طلب تحسين رائع لتبسيط الإعداد لتثبيت Discourse يحتوي على العديد من الفئات الفرعية تحت عدد قليل من الفئات الأصلية.

لا يمكن الاشتراك في جميع الفئات بقاعدة واحدة

وجدت بعض المعلومات المتضاربة حول هذا الأمر، وأفترض أن ملحق Slack الأقدم سمح بذلك، لكنني لم أجد طريقة لإنشاء قاعدة واحدة تقوم بالاشتراك ببساطة في جميع المنشورات والردود من جميع الفئات في الموقع. كنت آمل في القيام بذلك كلّه في قاعدة واحدة بسيطة. لكن بسبب هذا والنقطة أعلاه، استغرق الأمر 31 قاعدة منفصلة بدلاً من قاعدة واحدة فقط لإنشاء جسر أساسي بين منصة Discourse بأكملها وقناة Slack. ما لم أكن قد أغفلت شيئًا، يرجى اعتبار هذا طلب تحسين أيضًا.

أمر منشور Discourse يعمل فقط في قناة واحدة

الآن، هذا على الأرجح خطئي، لكنني لم أستطع فهمه. لقد مررت عبر جميع المواضيع في هذا الشأن، وأود الحصول على بعض المساعدة. لقد تحققت مرتين من أذونات تطبيق Slack الخاص بي، وأستطيع تأكيد أنه يعمل تمامًا 100%… في قناة واحدة فقط!

/discourse post 20

لذا أعرف أن رمز الوصول مُعد ويعمل بشكل جيد. ومع ذلك، في جميع القنوات الأخرى في فريق Slack الخاص بي، يُخرج الأمر أعلاه ببساطة:

Loading the transcript...

وهذا كل شيء. جميع هذه القنوات عامة، وقد جربت كل تركيبة ممكنة من الإعدادات. القناة الوحيدة التي تعمل تم إنشاؤها اليوم، لكن عندما أنشأت قناة جديدة أخرى للاختبار، لم تعمل. لا أعرف حتى من أين أبدأ في استكشاف الأخطاء وإصلاحها. السجلات الوحيدة التي أعرفها في Discourse هي:

./launcher logs app

ولكن لا يبدو أن هناك أي شيء هناك على الإطلاق. ما الإعداد الذي قد أغفلته والذي يسمح بالعمل فقط في قناة واحدة، وأين يمكنني البحث عن تصحيح هذا؟