Slack Bot Framework

xuanbao · · 27 次点击    
<p>Hello! I was working on a project where we used the Micro framework (<a href="https://github.com/micro/go-micro" rel="nofollow">https://github.com/micro/go-micro</a>) to build and manage an orchestrated system of micro services to solve the problems we were tackling. One of the nice features of the Micro framework is that it provides you with Slack Integration. Unfortunately, it had a few shortcomings.</p> <p>1) Large messages/results (over 4000 characters) are dropped by Slack (Thus we had to truncate) 2) No file upload features (We wanted to upload those large results instead of truncating them) 3) Bot responds in channels only if it was mentioned as the first word of the sentence (Example: @bot help) 4) Command input had to be exactly equal and case sensitive to what the user typed (If the command is &#34;help&#34; but the user typed, &#34;help me&#34;, or &#34;I need help&#34; or &#34;HELP&#34;, it would not respond) 5) Command parameters were passed as an argument array rather than a map. 6) We had to have a micro service for the default Slack Integration (which came with some default commands) but a new micro service per custom command</p> <p>I researched for bot frameworks that offer more features and capabilities that integrate with Slack. While I found a few, they did not give us everything we wanted and not all were written in Go. The best Slack Integration I found is <a href="https://github.com/nlopes/slack" rel="nofollow">https://github.com/nlopes/slack</a>, but it is not a Bot Framework. So you would need to write some code to work with the Real Time Messaging features to create Bot commands.</p> <p>So in my free time, I put together and open-sourced <a href="https://github.com/shomali11/slacker" rel="nofollow">https://github.com/shomali11/slacker</a> to make Slack Bot Integration so simple anyone can write a Slack Bot in Golang. It is built on top of <a href="https://github.com/nlopes/slack" rel="nofollow">https://github.com/nlopes/slack</a> and encapsulates the Real Time Messaging feature. This makes writing bot commands very easy.</p> <p>I am quite honored to see that there are a few already interested in it and that it was accepted to be part of list of awesome Golang libraries (<a href="https://github.com/avelino/awesome-go" rel="nofollow">https://github.com/avelino/awesome-go</a>).</p> <p>Your feedback, suggestions, forks, issues, stars and PRs are more than welcome and appreciated. :)</p> <hr/>**评论:**<br/><br/>hcwool: <pre><p>I don&#39;t have any specific experience with the frameworks you&#39;re using - but I do know that the 4000 character limit is enforced by the Slack API (ie. You can&#39;t get around it by simply changing libraries). So, I&#39;m curious how your client gets around this.</p></pre>shomali11: <pre><p>My apologies for the confusion. You are right, it is enforced by the Slack API, which is why we wanted to upload the results as a file/snippet instead.</p> <p>Because the upload file feature was not available as part of Micro&#39;s Slack Integration, we had to truncate.</p> <p><a href="https://github.com/nlopes/slack" rel="nofollow">https://github.com/nlopes/slack</a> supports all (as far as I know) of Slack&#39;s features (including uploading files). The framework I put together is built on top of its Real Time Messaging features but it also gives you full access to the API should you choose to want to upload a file for example.</p></pre>gophergo: <pre><p><a href="https://beepboophq.com" rel="nofollow">https://beepboophq.com</a> provides a go option, the service is free to try for 7 days and relatively inexpensive with the paid option. Follow the steps and it will create a repo for you with a go starter project.</p></pre>
27 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet