Slack
Ringkasan
Section titled “Ringkasan”Provider Slack mengintegrasikan digital worker Anda dengan workspace Slack. Provider ini mendukung:
- Direct message (DM)
- Pesan channel
- Mention app
- Komponen interaktif (tombol, menu)
- Pesan kaya Block Kit
- Slash command
- Balasan thread
Prasyarat
Section titled “Prasyarat”- Sebuah workspace Slack
- Akses admin untuk membuat app Slack
Penyiapan
Section titled “Penyiapan”-
Buat pasangan token konfigurasi Slack
Buka api.slack.com/apps dan buat pasangan token konfigurasi app. Salin kedua nilai:
- Token akses konfigurasi (
xoxe.xoxp-...) - Token refresh konfigurasi (
xoxe-1-...)
- Token akses konfigurasi (
-
Konfigurasikan provider
answers.json {"setup_answers": {"messaging-slack": {"slack_configuration_access_token": "xoxe.xoxp-xxx","slack_configuration_refresh_token": "xoxe-1-xxx"}}} -
Jalankan setup
Terminal window gtc setup --answers answers.json ./my-bundle -
Klik Add to Slack
Setup mendaftarkan atau memperbarui app Slack dan menampilkan aksi Add to Slack. Buka URL otorisasi Slack yang dibuat, pilih workspace, tinjau scope yang diminta, lalu setujui instalasi.
Saat redirect OAuth kembali ke setup, Greentic menyimpan Slack app id, client id, client secret, dan jawaban OAuth runtime untuk tenant. Jika callback tidak ditangani otomatis, jalankan
gtc setup --answers answers.json ./my-bundlelagi setelah menyetujui instalasi. -
Tambahkan app di Slack
Buka Slack dan pastikan app sudah terinstal di workspace. Untuk percakapan channel, tambahkan app ke channel tempat worker harus merespons. Anda dapat melakukannya dari pengaturan integrasi channel atau dengan menyebut/mengundang app di channel.
-
Mulai atau mulai ulang runtime
Terminal window gtc start ./my-bundleSaat startup,
slack_app_idyang tersimpan dan pasangan token konfigurasi digunakan untuk memperbarui manifest app Slack dengan URL webhook saat ini. -
Uji channel
Kirim direct message ke app atau mention app di channel Slack tempat Anda menambahkannya. Event channel hanya masuk untuk channel tempat app menjadi anggota dan scope terpasang mengizinkan event tersebut.
Opsi Konfigurasi
Section titled “Opsi Konfigurasi”| Opsi | Wajib | Deskripsi |
|---|---|---|
slack_configuration_access_token | Ya | Token konfigurasi Slack berumur pendek yang digunakan untuk pembaruan manifest app |
slack_configuration_refresh_token | Ya | Token refresh yang digunakan untuk merotasi token akses konfigurasi |
slack_app_id | Dibuat | Slack app id yang dibuat atau dikembalikan oleh setup |
slack_client_id | Dibuat | Slack OAuth client id yang dikembalikan oleh pendaftaran app |
client_secret | Secret dibuat | Slack OAuth client secret yang dikembalikan oleh pendaftaran app |
Pesan Teks
Section titled “Pesan Teks”- id: reply type: reply config: message: "Hello! How can I help you?"Pemformatan Markdown
Section titled “Pemformatan Markdown”Slack menggunakan format mrkdwn:
- id: formatted type: reply config: message: | *Bold* _Italic_ `code` >Blockquote • Bullet pointPesan Block Kit
Section titled “Pesan Block Kit”Gunakan Block Kit milik Slack untuk layout kaya:
- id: rich_message type: reply config: blocks: - type: section text: type: mrkdwn text: "*Welcome!*\nHow can I assist you today?" - type: divider - type: actions elements: - type: button text: type: plain_text text: "Get Help" action_id: "help_clicked" value: "help" - type: button text: type: plain_text text: "View Status" action_id: "status_clicked" value: "status"Tombol Interaktif
Section titled “Tombol Interaktif”- id: ask_action type: reply config: message: "What would you like to do?" blocks: - type: actions elements: - type: button text: type: plain_text text: "Create Ticket" style: primary action_id: "create_ticket" - type: button text: type: plain_text text: "Cancel" style: danger action_id: "cancel"Menu Pilihan
Section titled “Menu Pilihan”- id: select_option type: reply config: blocks: - type: section text: type: mrkdwn text: "Select a category:" accessory: type: static_select action_id: "category_select" options: - text: type: plain_text text: "Technical Support" value: "technical" - text: type: plain_text text: "Billing" value: "billing" - text: type: plain_text text: "General" value: "general"Balasan Thread
Section titled “Balasan Thread”Balas dalam thread:
- id: thread_reply type: reply config: message: "This replies in the thread" thread_ts: "{{original_message.thread_ts}}"Unggah File
Section titled “Unggah File”API file Slack berubah dari waktu ke waktu. Gunakan ini hanya ketika pack messaging-slack yang terpasang mengekspos dukungan file untuk versi Anda; jika tidak, kirim tautan atau gunakan alur upload eksternal Slack saat ini.
- id: upload_file type: reply config: files: - url: "https://example.com/report.pdf" filename: "report.pdf" title: "Monthly Report"Pesan Ephemeral
Section titled “Pesan Ephemeral”Pesan yang hanya terlihat oleh satu pengguna:
- id: ephemeral type: reply config: message: "Only you can see this" ephemeral: true user: "{{user_id}}"Menangani Interaksi
Section titled “Menangani Interaksi”Klik Tombol
Section titled “Klik Tombol”name: handle_interactionversion: "1.0"
nodes: - id: route_action type: branch config: conditions: - expression: "action_id == 'help_clicked'" to: show_help - expression: "action_id == 'create_ticket'" to: create_ticket default: unknown_action
- id: show_help type: reply config: message: "Here's how I can help..."
triggers: - type: block_action target: route_actionPerubahan Select Menu
Section titled “Perubahan Select Menu”- id: handle_select type: branch config: conditions: - expression: "selected_value == 'technical'" to: technical_flow - expression: "selected_value == 'billing'" to: billing_flowSlash Commands
Section titled “Slash Commands”- Buka Slash Commands di pengaturan app Anda
- Buat command (misalnya,
/support) - Atur Request URL ke webhook Anda
Tangani di flow Anda:
name: slash_commandversion: "1.0"
nodes: - id: handle_command type: reply config: message: "Support bot at your service!" response_type: in_channel # or "ephemeral"
triggers: - type: slash_command command: "/support" target: handle_commandKonfigurasi Channel
Section titled “Konfigurasi Channel”Channel Tunggal
Section titled “Channel Tunggal”tenants: demo: teams: support: channels: slack: provider: messaging-slack config: channel_id: "C1234567890"Banyak Channel
Section titled “Banyak Channel”tenants: demo: teams: support: channels: slack-general: provider: messaging-slack config: channel_id: "C1234567890" slack-vip: provider: messaging-slack config: channel_id: "C0987654321"Troubleshooting
Section titled “Troubleshooting”App Tidak Menerima Pesan
Section titled “App Tidak Menerima Pesan”-
Verifikasi Event Subscriptions:
- Periksa apakah Request URL benar
- Pastikan event diaktifkan
- Verifikasi bot berlangganan ke event yang benar
-
Periksa Izin Bot:
- Install ulang app setelah menambahkan scope
- Pastikan bot ada di channel
-
Uji Webhook:
Terminal window curl https://your-domain.com/v1/messaging/ingress/messaging-slack/demo/default
Error “not_authed”
Section titled “Error “not_authed””Bot token Anda tidak valid atau sudah kedaluwarsa. Ambil token baru dari OAuth & Permissions.
Error “channel_not_found”
Section titled “Error “channel_not_found””- Verifikasi channel ID sudah benar
- Pastikan bot ditambahkan ke channel
- Periksa apakah channel tidak diarsipkan
Rate Limiting
Section titled “Rate Limiting”Rate limit Slack bervariasi per metode. Tangani dengan baik:
- id: reply type: reply config: message: "Response" retry_on_rate_limit: true max_retries: 3Keamanan
Section titled “Keamanan”Greentic secara otomatis memvalidasi:
- Timestamp request
- Signature menggunakan signing secret
- Verifikasi token
Langkah Berikutnya
Section titled “Langkah Berikutnya”- Block Kit Builder - Rancang pesan kaya
- Provider Teams - Tambahkan integrasi Teams