Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
golangで作るslackbot
Search
Takumi Yoshida
September 01, 2017
Technology
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
golangで作るslackbot
Takumi Yoshida
September 01, 2017
More Decks by Takumi Yoshida
See All by Takumi Yoshida
GKEでは StackDriver Loggingに どうやってログを送っているか
ytakky2014
3
5.5k
Auralization of Tech News +Change in technology interest for my 4 years.
ytakky2014
0
130
Webメディアでのdataflow活用
ytakky2014
1
580
睡眠をエンジニアリングする
ytakky2014
0
290
PHP7+Laravel5.3 on Google App Engine
ytakky2014
0
1.3k
DevOps In All About
ytakky2014
0
3.6k
Other Decks in Technology
See All in Technology
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
30
18k
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.6k
AIで社員の自主発信に広報目線を組み込む
_mossann_t
0
140
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
540
データ_AIの事業の勝敗をわけるもの
nek0128
1
470
作って終わりじゃないサーバーレス 〜9年運用する大規模EC物流API基盤の設計・運用のリアル〜
zozotech
PRO
0
440
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
510
人間はどの意思決定を手放せるのか
kawasima
15
7.9k
品質と信頼性を地続きにする
grimoh
2
910
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
5
25k
あけおめLINE 傾向とその対策
nasa9084
0
240
AI時代の「技術的負債」の変質ー概念の終焉と再解釈、エージェントと共に向かう先
nwiizo
1
3.2k
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
830
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Deep Space Network (abreviated)
tonyrice
0
320
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
430
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
Ethics towards AI in product and experience design
skipperchong
2
380
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
The World Runs on Bad Software
bkeepers
PRO
72
12k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Transcript
golangͰ࡞Δslack bot @y_takky2014
• εϥΠυதͷGopher Renée FrenchʹΑͬͯσβΠϯ͞Ε·ͨ͠ http://reneefrench.blogspot.com/ • εϥΠυ্ͷ GopherͷҰ෦ը૾ @tenten͞Μͷ gopher-stickersΛ༻͍ͯ͠·͢
(https://github.com/tenntenn/gopher-stickers)
ΞδΣϯμ • ͳͥ golang ͰBotΛ࡞Δͷ͔ • golangͰͷSlackBotͷ࣮ํ๏(Sample) • ※SampleϓϩάϥϜطଘͷBotΛݩʹ ۀ࣌ؒ֎Ͱͬ͘͞ͱ࡞ͬͨͷ
SlackBotͷ࡞Γํ • hubot • Botkit • API (Rest / WebSocket)
hubot • botΛ࡞͢ΔͨΊͷϑϨʔϜϫʔΫ • AdapterͷΓସ͑Ͱͦͷ··πʔϧͷҠߦ͕Մೳ • coffeescript
botkit • ಛఆͷαʔϏε(slackFacebook)ʹಛԽͨ͠ Bot࡞ϑϨʔϜϫʔΫ • Interactive Button͕ѻ͍͍͢ • Node.js
API (Rest / WebSocket) • Slack͕ఏڙ͍ͯ͠ΔAPIͰϝοηʔδΛૹ৴͢Δ • API͕ఏڙ͞Ε͍ͯΕͳΜͰͰ͖Δ • ͍ΘΏΔWebAPIϕʔεͷͷͱ
WebSocketϕʔεͷͷͷ2छྨ • ࣮ݴޠΘͣ • ࠓճgolang
ͳͥgolangͳͷ͔? • ίϯύΠϧ͠ͱ͚࣮ߦڥΘͣ • ଞγεςϜͱ࿈ܞ͢Δ࣌ʹ࣮͍͢͠
४උ • https://api.slack.com/bot-users ͷ new bot user integration͔Βslack botΛ࡞͢Δ •
API_TOKENϝϞ͓ͬͯ͘ • botͷը૾͓ΈͰ
४උ • ඞཁͳIDΛऔಘ͓ͯ͘͠ • channel IDͷऔಘ • https://api.slack.com/methods/channels.list/test • BotIDͷऔಘ
• https://api.slack.com/methods/users.list/test
golangͰͲ͏࣮͢Δ͔ • https://github.com/nlopes/slack Λ͏ • Installing • go get -u
github.com/nlopes/slack
1. ఆظతʹϝοηʔδΛૹ৴͢Δ • github.com/robfig/cronΛ͏ • golang্Ͱఆظ࣮ߦΛαϙʔτ͢ΔϥΠϒϥϦ
// slack ClientΛͭ͘Δ api : = slack.New(API_TOKEN) // slack Real
Time Messaging APIΛ͏ rtm := api.NewRTM() // webSocketΛฒྻͰ࣮ߦ͢Δ go rtm.ManageConnection() // cronΛ࡞͢Δɻ 5ຖʹRTM APIͰϝοηʔδΛಛఆCHANNEL_IDʹૹΔ c := cron.New() c.AddFunc(“0 */5 * * * *”, func () {rtm.SendMessage(rtm.NewOutgoingMessage(“test”, CHANNEL_ID))}) c.Start()
None
2. ϝϯγϣϯʹԠ͢Δ
• 1ͱಉ༷ʹSlack Client / RTMͷwebsocketΛฒྻ࣮ߦ • ແݶϧʔϓʹͯ͠ɺແݶϧʔϓͰSlackͰड͚औͬͨΠϕϯτ ຖʹॲཧΛذ • Message
EventͩͬͨΒɺMessageͷ༰Λݟͯ @BotIDʹҰக͢ΔͷͩͬͨΒॲཧΛଓߦ • botUserΛ࡞Δ • Message EventͷൃݴऀͷID͔ΒNameΛऔಘͯ͠ ड͚औͬͨϝοηʔδΛͦͷ··ฦ٫
None
3. ఱؾ༧ใػೳΛ͚Δ • ϝϯγϣϯʹԠͯ͠ఱؾΛڭ͑ͯ͘ΕΔΑ͏ʹ͢Δ • livedoorͷఏڙ͍ͯ͠ΔWeather Hacks APIΛ༻͢Δ
APIୟ͍ͨ݁ՌΛ͍͍͢ܗʹܗͯ͠ฦ٫͢Δ
• @bot ఱؾ ͷ߹ఱؾΛڭ͑ͯ͘ΕΔΑ͏ʹ͢Δ • ఱؾAPIΛୟ͍ͨ݁Ռͷmap(࿈ྻ)Λճͯ͠ ݁ՌΛPost
None
·ͱΊ • golangͰͷbot࣮ྫΛհ • golangϥΠϒϥϦ͕ଟʑ͋ΔͷͰ ֎෦APIͱͷܨ͗ࠐ͕͔ͳΓָ • ֎෦ίϚϯυ࣮ߦΓ͍͢
ࢀߟ • golang Ͱ࢝ΊΔ Slack bot ։ൃ • http://blog.kaneshin.co/entry/2016/12/03/162653 •
GolangͰSlack Interactive MessageΛͬͨBotΛॻ͘ • http://tech.mercari.com/entry/2017/05/23/095500 • Gopher Stickers • https://github.com/tenntenn/gopher-stickers
• ΦϦδφϧͷGopher Renee FrenchʹΑͬͯσβΠϯ ͞Ε·ͨ͠ɻ • εϥΠυ্ͷ GopherͷҰ෦ը૾ @tenten͞Μͷ gopher-stickersΛ༻͍ͯ͠·͢
(https://github.com/tenntenn/gopher-stickers)