slack-smart-bot 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +237 -48
  3. data/img/chat_gpt.png +0 -0
  4. data/img/chat_gpt_session.png +0 -0
  5. data/img/chat_gpt_share.png +0 -0
  6. data/img/command_add_sc.png +0 -0
  7. data/img/command_bot_help_echo.png +0 -0
  8. data/img/command_loop.png +0 -0
  9. data/img/command_my_timeoff.png +0 -0
  10. data/img/command_recap.png +0 -0
  11. data/img/command_repl1.png +0 -0
  12. data/img/command_repl2.png +0 -0
  13. data/img/command_ruby.png +0 -0
  14. data/img/command_run_repl.png +0 -0
  15. data/img/command_see_announcements.png +0 -0
  16. data/img/command_see_statuses.png +0 -0
  17. data/img/command_see_team.png +0 -0
  18. data/img/command_summarize.png +0 -0
  19. data/img/commands_inline.png +0 -0
  20. data/img/commands_on_demand.png +0 -0
  21. data/img/commands_on_external_call.png +0 -0
  22. data/img/image_editing.png +0 -0
  23. data/img/image_generation.png +0 -0
  24. data/img/image_variations.png +0 -0
  25. data/img/openai-300.png +0 -0
  26. data/img/openai.png +0 -0
  27. data/img/slack-300.png +0 -0
  28. data/img/slack.png +0 -0
  29. data/img/smart-bot-150.png +0 -0
  30. data/img/smart-bot-profile-pic-2.png +0 -0
  31. data/img/smart-bot-profile-pic.png +0 -0
  32. data/img/smart-bot.png +0 -0
  33. data/img/whisper.png +0 -0
  34. data/lib/slack/smart-bot/ai/open_ai/connect.rb +165 -43
  35. data/lib/slack/smart-bot/ai/open_ai/models.rb +61 -9
  36. data/lib/slack/smart-bot/ai/open_ai/send_gpt_chat.rb +67 -11
  37. data/lib/slack/smart-bot/ai/open_ai/send_image_edit.rb +4 -3
  38. data/lib/slack/smart-bot/ai/open_ai/send_image_generation.rb +4 -4
  39. data/lib/slack/smart-bot/ai/open_ai/send_image_variation.rb +4 -3
  40. data/lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb +4 -3
  41. data/lib/slack/smart-bot/comm/ask.rb +20 -8
  42. data/lib/slack/smart-bot/comm/dont_understand.rb +2 -2
  43. data/lib/slack/smart-bot/comm/event_hello.rb +30 -1
  44. data/lib/slack/smart-bot/comm/get_channel_members.rb +2 -1
  45. data/lib/slack/smart-bot/comm/get_presence.rb +1 -0
  46. data/lib/slack/smart-bot/comm/get_smartbot_team_info.rb +10 -0
  47. data/lib/slack/smart-bot/comm/get_user_info.rb +45 -6
  48. data/lib/slack/smart-bot/comm/get_users.rb +8 -1
  49. data/lib/slack/smart-bot/comm/respond.rb +225 -196
  50. data/lib/slack/smart-bot/comm/send_msg_channel.rb +2 -2
  51. data/lib/slack/smart-bot/comm/send_msg_user.rb +10 -9
  52. data/lib/slack/smart-bot/comm/unreact.rb +2 -2
  53. data/lib/slack/smart-bot/comm.rb +1 -0
  54. data/lib/slack/smart-bot/commands/general/add_admin.rb +16 -6
  55. data/lib/slack/smart-bot/commands/general/add_announcement.rb +3 -3
  56. data/lib/slack/smart-bot/commands/general/add_vacation.rb +28 -12
  57. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat.rb +272 -23
  58. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_add_collaborator.rb +42 -0
  59. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_copy_session.rb +89 -0
  60. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_delete_session.rb +45 -0
  61. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_get_prompts.rb +41 -0
  62. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_list_sessions.rb +81 -0
  63. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_share_session.rb +52 -0
  64. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat_use_model.rb +52 -0
  65. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_edit_image.rb +14 -11
  66. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_generate_image.rb +15 -11
  67. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_models.rb +29 -17
  68. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_variations_image.rb +16 -13
  69. data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_whisper.rb +13 -7
  70. data/lib/slack/smart-bot/commands/general/allow_access.rb +8 -4
  71. data/lib/slack/smart-bot/commands/general/bot_help.rb +24 -9
  72. data/lib/slack/smart-bot/commands/general/bye_bot.rb +9 -5
  73. data/lib/slack/smart-bot/commands/general/delete_announcement.rb +2 -1
  74. data/lib/slack/smart-bot/commands/general/delete_share.rb +2 -1
  75. data/lib/slack/smart-bot/commands/general/deny_access.rb +1 -1
  76. data/lib/slack/smart-bot/commands/general/get_smartbot_readme.rb +15 -0
  77. data/lib/slack/smart-bot/commands/general/hi_bot.rb +10 -4
  78. data/lib/slack/smart-bot/commands/general/personal_settings.rb +26 -8
  79. data/lib/slack/smart-bot/commands/general/poster.rb +26 -2
  80. data/lib/slack/smart-bot/commands/general/public_holidays.rb +14 -24
  81. data/lib/slack/smart-bot/commands/general/recap.rb +399 -0
  82. data/lib/slack/smart-bot/commands/general/remove_admin.rb +19 -9
  83. data/lib/slack/smart-bot/commands/general/remove_vacation.rb +23 -6
  84. data/lib/slack/smart-bot/commands/general/see_access.rb +2 -1
  85. data/lib/slack/smart-bot/commands/general/see_admins.rb +8 -4
  86. data/lib/slack/smart-bot/commands/general/see_announcements.rb +5 -5
  87. data/lib/slack/smart-bot/commands/general/see_favorite_commands.rb +4 -4
  88. data/lib/slack/smart-bot/commands/general/see_shares.rb +1 -1
  89. data/lib/slack/smart-bot/commands/general/see_vacations.rb +34 -17
  90. data/lib/slack/smart-bot/commands/general/set_public_holidays.rb +4 -2
  91. data/lib/slack/smart-bot/commands/general/share_messages.rb +3 -3
  92. data/lib/slack/smart-bot/commands/general/summarize.rb +191 -0
  93. data/lib/slack/smart-bot/commands/general/teams/add_team.rb +4 -8
  94. data/lib/slack/smart-bot/commands/general/teams/delete_team.rb +3 -3
  95. data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team.rb +34 -29
  96. data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team_comment.rb +1 -1
  97. data/lib/slack/smart-bot/commands/general/teams/memos/delete_memo_team.rb +6 -4
  98. data/lib/slack/smart-bot/commands/general/teams/memos/see_memo_team.rb +26 -15
  99. data/lib/slack/smart-bot/commands/general/teams/memos/see_memos_team.rb +33 -24
  100. data/lib/slack/smart-bot/commands/general/teams/memos/set_memo_status.rb +4 -4
  101. data/lib/slack/smart-bot/commands/general/teams/ping_team.rb +10 -8
  102. data/lib/slack/smart-bot/commands/general/teams/see_teams.rb +73 -61
  103. data/lib/slack/smart-bot/commands/general/teams/see_vacations_team.rb +28 -13
  104. data/lib/slack/smart-bot/commands/general/teams/update_team.rb +9 -9
  105. data/lib/slack/smart-bot/commands/general_bot_commands.rb +1153 -835
  106. data/lib/slack/smart-bot/commands/on_bot/add_shortcut.rb +19 -17
  107. data/lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb +12 -9
  108. data/lib/slack/smart-bot/commands/on_bot/admin/remove_routine.rb +2 -0
  109. data/lib/slack/smart-bot/commands/on_bot/admin/run_routine.rb +1 -0
  110. data/lib/slack/smart-bot/commands/on_bot/admin/see_routines.rb +5 -3
  111. data/lib/slack/smart-bot/commands/on_bot/admin_master/delete_message.rb +2 -3
  112. data/lib/slack/smart-bot/commands/on_bot/admin_master/get_bot_logs.rb +2 -3
  113. data/lib/slack/smart-bot/commands/on_bot/admin_master/react_to.rb +2 -3
  114. data/lib/slack/smart-bot/commands/on_bot/admin_master/send_message.rb +7 -6
  115. data/lib/slack/smart-bot/commands/on_bot/admin_master/update_message.rb +2 -3
  116. data/lib/slack/smart-bot/commands/on_bot/delete_repl.rb +1 -1
  117. data/lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb +21 -20
  118. data/lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb +40 -7
  119. data/lib/slack/smart-bot/commands/on_bot/general/bot_status.rb +6 -2
  120. data/lib/slack/smart-bot/commands/on_bot/general/stop_using_rules.rb +7 -6
  121. data/lib/slack/smart-bot/commands/on_bot/general/suggest_command.rb +5 -4
  122. data/lib/slack/smart-bot/commands/on_bot/general/use_rules.rb +4 -3
  123. data/lib/slack/smart-bot/commands/on_bot/get_repl.rb +4 -4
  124. data/lib/slack/smart-bot/commands/on_bot/kill_repl.rb +1 -1
  125. data/lib/slack/smart-bot/commands/on_bot/repl.rb +110 -53
  126. data/lib/slack/smart-bot/commands/on_bot/repl_client.rb +35 -29
  127. data/lib/slack/smart-bot/commands/on_bot/run_repl.rb +5 -5
  128. data/lib/slack/smart-bot/commands/on_bot/see_repls.rb +1 -2
  129. data/lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb +5 -4
  130. data/lib/slack/smart-bot/commands/on_extended/bot_rules.rb +22 -11
  131. data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +12 -7
  132. data/lib/slack/smart-bot/commands/on_master/admin_master/notify_message.rb +2 -2
  133. data/lib/slack/smart-bot/commands/on_master/admin_master/publish_announcements.rb +1 -1
  134. data/lib/slack/smart-bot/commands/on_master/admin_master/set_general_message.rb +5 -5
  135. data/lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb +5 -5
  136. data/lib/slack/smart-bot/commands/on_master/create_bot.rb +3 -3
  137. data/lib/slack/smart-bot/commands.rb +10 -0
  138. data/lib/slack/smart-bot/config.rb +126 -0
  139. data/lib/slack/smart-bot/listen.rb +12 -11
  140. data/lib/slack/smart-bot/process.rb +62 -55
  141. data/lib/slack/smart-bot/process_first.rb +106 -65
  142. data/lib/slack/smart-bot/treat_message.rb +79 -47
  143. data/lib/slack/smart-bot/utils/answer.rb +11 -3
  144. data/lib/slack/smart-bot/utils/answer_delete.rb +11 -3
  145. data/lib/slack/smart-bot/utils/check_vacations.rb +21 -3
  146. data/lib/slack/smart-bot/utils/create_routine_thread.rb +13 -13
  147. data/lib/slack/smart-bot/utils/display_calendar.rb +42 -8
  148. data/lib/slack/smart-bot/utils/encryption/decrypt.rb +16 -9
  149. data/lib/slack/smart-bot/utils/encryption/encrypt.rb +14 -11
  150. data/lib/slack/smart-bot/utils/find_user.rb +71 -0
  151. data/lib/slack/smart-bot/utils/get_access_channels.rb +22 -3
  152. data/lib/slack/smart-bot/utils/get_channels_name_and_id.rb +3 -4
  153. data/lib/slack/smart-bot/utils/get_command_ids.rb +5 -5
  154. data/lib/slack/smart-bot/utils/get_countries_candelarific.rb +18 -0
  155. data/lib/slack/smart-bot/utils/get_help.rb +21 -19
  156. data/lib/slack/smart-bot/utils/get_openai_sessions.rb +47 -0
  157. data/lib/slack/smart-bot/utils/get_personal_settings.rb +29 -3
  158. data/lib/slack/smart-bot/utils/get_rules_imported.rb +27 -6
  159. data/lib/slack/smart-bot/utils/get_shares.rb +1 -1
  160. data/lib/slack/smart-bot/utils/get_team_members.rb +4 -4
  161. data/lib/slack/smart-bot/utils/get_vacations.rb +15 -7
  162. data/lib/slack/smart-bot/utils/has_access.rb +10 -4
  163. data/lib/slack/smart-bot/utils/is_admin.rb +25 -17
  164. data/lib/slack/smart-bot/utils/local_time.rb +29 -0
  165. data/lib/slack/smart-bot/utils/save_stats.rb +5 -3
  166. data/lib/slack/smart-bot/utils/update_access_channels.rb +19 -3
  167. data/lib/slack/smart-bot/utils/update_openai_sessions.rb +42 -0
  168. data/lib/slack/smart-bot/utils/update_personal_settings.rb +11 -3
  169. data/lib/slack/smart-bot/utils/update_rules_imported.rb +18 -3
  170. data/lib/slack/smart-bot/utils/update_vacations.rb +5 -2
  171. data/lib/slack/smart-bot/utils/upgrade_to_use_team_ids.rb +276 -0
  172. data/lib/slack/smart-bot/utils.rb +6 -1
  173. data/lib/slack-smart-bot.rb +182 -76
  174. data/lib/slack-smart-bot_general_commands.rb +10 -9
  175. data/whats_new.txt +30 -13
  176. metadata +152 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37c704bfddd83d7a7d34f9b15cea3cf8d1f01dde28c11c9e9bea01fb6ac9db19
4
- data.tar.gz: 9785ce98b6695b77aaf89a0e239142e2443a4d812c2dcb1fe3119953f516d023
3
+ metadata.gz: 2c3c10ede28d806c5c386904621b877fdc1077f84f758b5affde34b3160340bf
4
+ data.tar.gz: 4db939606739e903c5d2916ea4d12409457eb3a62a8a740a0dec42f022f6bb70
5
5
  SHA512:
6
- metadata.gz: 8e287b2173246c2adc1805738c87a6428ef43776213294558e1e900b29a03094df9b16d44b3a754d7b52d6a774a1a44da946cb553c4a5c9e83ca76b651239a1a
7
- data.tar.gz: 9100ceee4ac4efd07a9ae4fae9d9014d00417626b0650bcd9bfa3824ff4070812cd9dfc79bbf26d68b088a43600ad22a469a40c137f4d9634066e9c2d133a596
6
+ metadata.gz: d204840c2f03710234fcc7f959b85256065cc312784cd5bb0f3e40aced01301a0a695c35e66161091d0b88e11d2e57283e47782752543240fff1ed00cda7ad0d
7
+ data.tar.gz: f06acd8003f313d2711710778e4a7119434d349107c4930e68800ef61620b367635ec047191061830711ee4c6eefbd5ade67eb06f320cdea2f249338cad22eb5
data/README.md CHANGED
@@ -8,17 +8,18 @@
8
8
  ![GitHub last commit](https://img.shields.io/github/last-commit/MarioRuiz/slack-smart-bot)
9
9
  ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/MarioRuiz/slack-smart-bot)
10
10
 
11
- Create a Slack bot that is really smart and so easy to expand.
11
+ Create a highly smart Slack bot that is incredibly easy to customize and expand.
12
12
 
13
- The main scope of this ruby gem is to be used internally in your company so teams can create team channels with their own bot to help them on their daily work, almost everything is suitable to be automated!!
13
+ The primary purpose of this Ruby gem is to be used internally within your company, allowing teams to create dedicated channels with their own bot to assist them with their daily tasks. Almost any task can be automated with ease!
14
14
 
15
- slack-smart-bot can create bots on demand, create shortcuts, run ruby code... just on a chat channel, you can access it just from your mobile phone if you want and run those tests you forgot to run, get the results, restart a server... no limits.
15
+ slack-smart-bot has the ability to create bots on demand, set up shortcuts, execute Ruby code, utilize ChatGPT, DALL-E, Whisper, and more. All of this can be done directly within a chat channel, even from your mobile phone. Whether you need to run forgotten tests, retrieve results, restart a server, summarize a channel or just a thread, or engage in a ChatGPT session, the possibilities are limitless.
16
16
 
17
- <img src="./img/smart-bot.png" width="150" height="150">![](./img/slack.png)
17
+ <img src="img/smart-bot-150.png"><img src="img/slack-300.png"><img src="img/openai-300.png">
18
18
 
19
19
  # Table of Contents
20
+ (A): Only for Admins
20
21
 
21
- - [Installation and configuration](#installation-and-configuration)
22
+ - [Installation and configuration](#installation-and-configuration) (A)
22
23
  - [Usage](#usage)
23
24
  * [creating the MASTER BOT](#creating-the-master-bot) (A)
24
25
  * [How to access the Smart Bot](#how-to-access-the-smart-bot)
@@ -41,22 +42,24 @@ slack-smart-bot can create bots on demand, create shortcuts, run ruby code... ju
41
42
  * [Teams](#teams)
42
43
  * [Time off management](#time-off-management)
43
44
  * [OpenAI](#openai)
44
- + [OpenAI Set up](#openai-setup)
45
+ + [OpenAI Set up](#openai-setup) (A)
45
46
  + [Chat GPT](#chatgpt)
46
47
  + [Image Generation](#image-generation)
47
48
  + [Image Variations](#image-variations)
48
49
  + [Image Editing](#image-editing)
49
50
  + [Whisper](#whisper)
50
51
  + [Models](#models)
52
+ * [Recap](#recap)
53
+ * [Summarize](#summarize)
54
+ * [Personal Settings](#personal-settings)
51
55
  * [Tips](#tips)
52
56
  + [Send a file](#send-a-file) (A)
53
57
  + [Download a file](#download-a-file) (A)
54
58
  - [Contributing](#contributing)
55
59
  - [License](#license)
56
60
 
57
- (A): Only for Admins
58
-
59
61
  ## Installation and configuration
62
+ > for admins
60
63
 
61
64
  $ gem install slack-smart-bot
62
65
 
@@ -72,7 +75,9 @@ settings = {
72
75
  # the channel that will act like the master channel, main channel
73
76
  master_channel: 'my_master_channel',
74
77
  masters: ["mario"], #names of the master users
75
- token: 'xxxxxxxxxxxxxxxxxx' # the API Slack token
78
+ token: 'xxxxxxxxxxxxxxxxxx', # the API Slack token
79
+ user_token: 'yyyyyyyyyy', # The API Slack User token
80
+ granular_token: 'zzzzzzzz' # The API Granular Slack Token
76
81
  }
77
82
 
78
83
  puts "Connecting #{settings.inspect}"
@@ -84,28 +89,87 @@ The master_channel will be the channel where you will be able to create other bo
84
89
 
85
90
  The masters will have full access to everything. You need to use the slack user name defined on https://YOUR_WORK_SPACE.slack.com/account/settings#username.
86
91
 
87
- For the token remember you need to generate a token on the Slack web for the bot user.
92
+ Create the SmartBot *[Slack App. Bot Token](https://api.slack.com/slack-apps)* :
93
+
94
+ 1) [Create a Classic Slack App](https://api.slack.com/apps?new_classic_app=1) This will be our *@smart-bot App* we will interact with. This App will use RTM to connect to Slack.
88
95
 
89
- You can get one by any of these options:
96
+ 1) Add a bot user to your app. On Add features and functionality section for your app, select *Bots*. Click on *Add a Legacy Bot User*
90
97
 
91
- - *[Slack App. Bot Token](https://api.slack.com/slack-apps)*. (Recommended)
98
+ 1) On your app click on the menu on the left: *OAuth & Permissions*. Add the 'users.profile:write' scope. This is necessary for the SmartBot to be able to change the slack status of other users.
99
+
100
+ 1) Now you will need to ask a workspace admin to click on *Install App to Workspace*.
92
101
 
93
- 1) [Create a Slack App](https://api.slack.com/apps?new_app=1)
102
+ 1) Copy your *Bot User OAuth Access Token* and add it to the SmartBot settings with key :token
94
103
 
95
- 1) Add a bot user to your app. On Add features and functionality section for your app, select *Bots*. Click on *Add a Bot User*
104
+ 1) Ask a workspace admin to provide the *User OAuth Token* and add it to the SmartBot settings with key :user_token
96
105
 
97
- 1) On your app click on the menu on the left: *OAuth & Permissions* and click on *Install App to Workspace*.
106
+ Now we will create the GranularSmartBot Slack App to get access to certain end points as a regular Slack App:
98
107
 
99
- 1) Copy your *Bot User OAuth Access Token*.
108
+ 1) [Create a Granular Slack App](https://api.slack.com/apps?new_app=1) This will be our @granular-smart-bot App. It will be used internally on the SmartBot. It is a regular Slack App with scopes.
100
109
 
110
+ 1) On your app click on the menu on the left: *OAuth & Permissions* and add on Bot Token Scopes the necessary Scopes: app_mentions:read, channels:history, channels:read, chat:write, chat:write.customize, emoji:read, files:read, groups:history, groups:read, im:history, im:read, im:write, incoming-webhook, mpim:history, mpim:read, mpim:write, reactions:read, reactions:write, team:read, users.profile:read, users:read, users:read.email
111
+
112
+ 1) Click on *Install App to Workspace*.
101
113
 
102
- - *[Legacy API Token](https://api.slack.com/custom-integrations/legacy-tokens)*.
114
+ 1) Copy the *Bot User OAuth Token* and add it to the SmartBot settings with the key :granular_token
103
115
 
116
+ Both Apps need to be on the channels we want to use the SmartBot.
104
117
 
105
- *Remember to invite the smart bot to the channels where they will be accessible before creating the bot*
118
+ *Remember to invite the smart bot to the channels where they will be accessible before starting the bot*
106
119
 
107
120
  SmartBot will notify about SmartBot status changes or any SmartBot incident if defined the status_channel in settings file and the channel exists. By default: smartbot-status
108
121
 
122
+
123
+ This is an example of typical settings to be supplied for the *Slack Smart Bot* instance:
124
+ ```ruby
125
+ settings = {
126
+ token: ENV["SLACK_BOT_TOKEN"],
127
+ user_token: ENV['SLACK_USER_TOKEN'],
128
+ granular_token: ENV['SLACK_GRANULAR_BOT_TOKEN'],
129
+ masters: ["mario", "peterv", "lisawhite"], #master admin users
130
+ master_channel: "smartbot_master",
131
+ silent: true,
132
+ stats: true,
133
+ encrypt: true,
134
+ encryption: { # if not encryption key supplied then it will be generated one using the host name and the Slack token
135
+ key: ENV['ENCRYPTION_KEY'],
136
+ iv: ENV['ENCRYPTION_IV']
137
+ },
138
+ github: {
139
+ token: ENV['GITHUB_TOKEN']
140
+ },
141
+ jira: {
142
+ host: ENV['JIRA_HOST'],
143
+ user: ENV['JIRA_USER'],
144
+ password: ENV['JIRA_PASSWORD']
145
+ },
146
+ public_holidays: {
147
+ api_key: ENV['CALENDARIFIC_API_KEY'],
148
+ default_calendar: 'spain/madrid'
149
+ },
150
+ ai: {
151
+ open_ai: {
152
+ access_token: ENV["OPENAI_ACCESS_TOKEN"],
153
+ chat_gpt: {
154
+ model: 'gpt-3.5-turbo-0613', # to be used by default for the user calling chatgpt command
155
+ smartbot_model: 'gpt-4-32k-0613' # to be used by default by the SmartBot internally
156
+ }
157
+ }
158
+ }
159
+ }
160
+
161
+ ```
162
+
163
+ You can see all the accepted settings on: [/lib/slack/smart-bot/config.rb](/lib/slack/smart-bot/config.rb)
164
+
165
+ To use the other integrated services:
166
+ * OpenAI: https://platform.openai.com/account/api-keys
167
+ * Calendarific: https://www.calendarific.com
168
+ * GitHub: https://github.com/settings/tokens
169
+ * Jira: https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/
170
+
171
+
172
+
109
173
  ## Usage
110
174
 
111
175
  ### creating the MASTER BOT
@@ -233,7 +297,7 @@ To run a command on demand and add the response on a thread:
233
297
 
234
298
  Examples run a command on demand:
235
299
 
236
- <img src="img/commands_on_demand.png" width="400">
300
+ <img src="img/commands_on_demand.png" width="500">
237
301
 
238
302
 
239
303
  Also you can always call the Smart Bot from any channel, even from channels without a running Smart Bot. You can use the External Call on Demand: **_`@NAME_OF_BOT on #CHANNEL_NAME COMMAND`_**. In this case you will call the bot on #CHANNEL_NAME. You can supply more than one channel then all the bots will respond. In case you are in a private conversation with the Smart Bot (DM) then you can use directly: **_`#CHANNEL_NAME COMMAND`_** or **_`on #CHANNEL_NAME COMMAND`_**
@@ -243,13 +307,13 @@ Examples:
243
307
  <img src="img/commands_on_external_call.png" width="400">
244
308
 
245
309
  Examples on DM:
246
- >**_Peter>_** `#sales show report from India`
310
+ >**_Peter>_** `#sales show report from India`
247
311
  >**_Peter>_** `on #sales notify clients`
248
312
 
249
313
  If you want the Smart Bot just listen to part of the message you send, add the commands you want using '`' and start the line with '-!', '-!!' or '-^'
250
314
 
251
315
  Examples:
252
- <img src="img/commands_inline.png" width="400">
316
+ <img src="img/commands_inline.png" width="500">
253
317
 
254
318
 
255
319
  All the commands specified on `./rules/general_commands.rb` will be accessible from any channel where the Smart Bot is present, without the necessity to call it with !, !!, ^ or on demand.
@@ -270,7 +334,7 @@ To show only the specific rules of the Smart Bot defined on the rules file: **_`
270
334
  Also you can call `suggest command` or `random command` and SmartBot will return the help content for a random command.
271
335
 
272
336
  Example:
273
- <img src="img/command_bot_help_echo.png" width="300">
337
+ <img src="img/command_bot_help_echo.png" width="250">
274
338
 
275
339
 
276
340
  When you call a command that is not recognized, you will get suggestions from the Smart Bot.
@@ -292,7 +356,7 @@ For the examples use _ and for the rules `. This is a good example of a Help sup
292
356
  # help: _execute smoke tests on db1_
293
357
  ```
294
358
 
295
- To see what's new just call `What's new`
359
+ To see what's new just call `What's new`. And to get the SmartBot README call `get smartbot readme`.
296
360
 
297
361
  ### Bot Management
298
362
  > for admins
@@ -350,7 +414,7 @@ Also you can always call the Smart Bot from any channel, even from channels with
350
414
  You can run Ruby code by using the command: **_`ruby THE_CODE`_**.
351
415
 
352
416
  Example:
353
- <img src="img/command_ruby.png" width="500">
417
+ <img src="img/command_ruby.png" width="650">
354
418
 
355
419
 
356
420
  Also it is possible to attach a Ruby file and the Smart Bot will run and post the output. You need to select Ruby as file format. Or if you prefer it you can call the `ruby` command and on the same message supply a code block.
@@ -358,6 +422,9 @@ Also it is possible to attach a Ruby file and the Smart Bot will run and post th
358
422
  #### REPL
359
423
  > for all users
360
424
 
425
+ For a quick introduction play this video:
426
+ [![SmartBot REPLs](https://img.youtube.com/vi/URMI3BdD7J8/0.jpg)](https://www.youtube.com/watch?v=URMI3BdD7J8)
427
+
361
428
  Easily starts a REPL session so you will be able to create a script directly from the slack conversation. You will be able to share the REPL so they can run it or see the content.
362
429
 
363
430
  It Will run all we write as a ruby command and will keep the session values until we finish the session sending `quit`, `exit` or `bye`
@@ -377,6 +444,8 @@ To pre-execute some ruby when starting the session add the code to `.smart-bot-r
377
444
 
378
445
  If you want to see the methods of a class or module you created use `ls TheModuleOrClass`. To see all documentation of a method: `doc TheModuleOrClass.method_name`. And to see the source code of a method: `code TheModuleOrClass.method_name`. Examples: `ls Sales`, `doc Sales.list`, `code Sales.list`
379
446
 
447
+ During the REPL session you can ask *ChatGPT* about the code or any other question. Just start the message with `?` and the Smart Bot will ask ChatGPT and will post the answer. Example: `? How to create a new customer?`. If you send just the question mark without a prompt then ChatGPT will suggest next code line. Example: `?`
448
+
380
449
  You can supply the Environmental Variables you need for the Session
381
450
 
382
451
  Examples:
@@ -388,9 +457,9 @@ Examples:
388
457
 
389
458
 
390
459
  Running Example:
391
- <img src="img/command_repl1.png" width="600">
460
+ <img src="img/command_repl1.png" width="650">
392
461
 
393
- <img src="img/command_repl2.png" width="600">
462
+ <img src="img/command_repl2.png" width="650">
394
463
 
395
464
 
396
465
  Runnning on demand the repl we created:
@@ -428,7 +497,7 @@ That shortcut will be available for you, in case you want to make it available f
428
497
 
429
498
  Example:
430
499
 
431
- <img src="img/command_add_sc.png" width="500">
500
+ <img src="img/command_add_sc.png" width="650">
432
501
 
433
502
 
434
503
  In case you want to use a shortcut as a inline shortcut inside a command you can do it by adding a $:
@@ -460,7 +529,7 @@ Examples:
460
529
 
461
530
  To see the announcements of the channel: **_`see announcements`_**, **_`see COLOR announcements`_**, **_`see EMOJI announcements`_** and to delete a particular announcement: **_`delete announcement ID`_**
462
531
 
463
- <img src="img/command_see_announcements.png" width="500">
532
+ <img src="img/command_see_announcements.png" width="650">
464
533
 
465
534
  If you are a master admin and you are on master channel then you can call **_`publish announcements`_** that will publish the announcements on all channels. The messages stored on a DM won't be published. This is very convenient to be called from a *Routine* for example every weekday at 09:00.
466
535
 
@@ -540,7 +609,7 @@ Examples:
540
609
  >**_`quit loop 1`_**
541
610
  >**_`stop iterator 12`_**
542
611
 
543
- <img src="img/command_loop.png" width="400">
612
+ <img src="img/command_loop.png" width="500">
544
613
 
545
614
  ### Control who has access to a command
546
615
  > for admins
@@ -574,7 +643,7 @@ If you want to change who has access to a specific command without restarting th
574
643
  # helpadmin:
575
644
  when /\A\s*update\s+access\s*\z/i
576
645
  save_stats(:update_access)
577
- if is_admin?(user.name)
646
+ if is_admin?()
578
647
  config.allow_access.repl = ['marioruiz', 'samcooke']
579
648
  respond "updated on <##{@channel_id}>!"
580
649
  else
@@ -589,7 +658,7 @@ if has_access?(:your_command_id)
589
658
  end
590
659
  ```
591
660
 
592
- Also you can allow or deny access for specific commands and users on any specific channel all you need is the Smartbot to be a member of the channel and use these commands on Slack:
661
+ Also you can allow or deny access for specific commands and users on any specific channel all you need is the Smartbot to be a member of the channel and use these commands on Slack:
593
662
  `allow access COMMAND_ID`
594
663
  `allow access COMMAND_ID @user1 @user99`
595
664
  It will allow the specified command to be used on the channel.
@@ -617,7 +686,10 @@ Examples:
617
686
  >**_`most used commands`_**
618
687
 
619
688
  ### Teams
620
- > for all users
689
+ > for all users
690
+
691
+ For a quick introduction play this video:
692
+ [![SmartBot Teams](https://img.youtube.com/vi/u8B4aGDXH9M/0.jpg)](https://www.youtube.com/watch?v=u8B4aGDXH9M)
621
693
 
622
694
  You can add, update, see, ping and delete teams. When calling `see TEAM_NAME team` the availability of the members will be displayed.
623
695
  `add team TEAM_NAME PROPERTIES` will add a team with the info supplied. In case it is supplied a channel with type 'members' the members of that channel would be considered members of the team.
@@ -676,7 +748,7 @@ Examples:
676
748
  >**_`sales team memo 4 Put it on hold until tests for Apple feature are finished`_**
677
749
  >**_`sales team memo 7`_**
678
750
 
679
- <img src="img/command_see_team.png" width="600">
751
+ <img src="img/command_see_team.png" width="650">
680
752
 
681
753
 
682
754
  Other team commands: **_`delete team TEAM_NAME`_**, **_`delete memo ID from team TEAM_NAME`_**, **_`set STATUS on memo ID TEAM_NAME team`_**, **_`see MEMO_TYPE from TEAM_NAME team TOPIC`_**
@@ -691,11 +763,10 @@ The vacation plan will be displayed also with the team when calling `see team NA
691
763
 
692
764
  Also, you can see the vacation plan for the team for a specific period: `vacations team NAME YYYY/MM/DD`
693
765
 
694
- To be able to use this command you need to allow the 'users.profile:write' scope on your Slack App and an admin user of the workspace needs to install the app. Set the user token on the SmartBot settings:
766
+ To be able to use this command you need to allow the 'users.profile:write' scope on your Slack App and an admin user of the workspace needs to install the app. Set the user token provided by the workspace on the SmartBot settings:
695
767
 
696
768
  ```ruby
697
769
  settings = {
698
- token: ENV["SLACK_BOT_TOKEN"],
699
770
  user_token: ENV['SLACK_USER_TOKEN']
700
771
  }
701
772
  ```
@@ -706,43 +777,70 @@ Add to your Smartbot configuration:
706
777
  ```ruby
707
778
  settings = {
708
779
  public_holidays: {
709
- api_key: API_KEY
780
+ api_key: ENV['CALENDARIFIC_API_KEY']
710
781
  }
711
782
  }
712
783
  ```
713
784
 
714
785
  When calling `see my time off` on a DM will display a calendar of the year with the days off, including public holidays
715
786
 
716
- <img src="img/command_my_timeoff.png" width="650">
787
+ <img src="img/command_my_timeoff.png" width="750">
717
788
 
718
789
  Other 'time off' commands: **_`remove time off ID`_**, **_`see my time off`_**, **_`see vacations @USER`_**, **_`time off team NAME`_**, **_`set public holidays to COUNTRY/REGION`_**
719
790
 
720
791
 
721
792
  ### OpenAI
722
- > for all users
793
+
723
794
  #### OpenAI setup
724
- To be able to use this SmartBot general command you need to ask for an API token: https://platform.openai.com/account/api-keys
795
+ > for admins
796
+
797
+ To be able to use this SmartBot general command you need to ask for an API token: https://platform.openai.com/account/api-keys or supply a Host and api_key for Azure OpenAI.
725
798
 
726
799
  Then specify in the SmartBot config the keys:
727
800
 
728
801
  ```ruby
729
802
  ai: {
803
+ # for all open_ai services
730
804
  open_ai: {
731
- access_token: 'OPENAI_ACCESS_TOKEN',
732
- organization_id: 'OPENAI_ORGANIZATION_ID',
733
- gpt_model: 'gpt-3.5-turbo',
734
- whisper_model : 'whisper-1',
735
- image_size: '256x256'
805
+ #default host and token for all openAI services
806
+ host: 'HOST', # optional
807
+ access_token: 'OPENAI_ACCESS_TOKEN',
808
+ # Optional. For chatGPT. If supplied it will be used instead of the ones defined for all open_ai services
809
+ chat_gpt: {
810
+ host: 'HOST',
811
+ access_token: 'OPENAI_ACCESS_TOKEN', #or OPENAI_API_KEY from Azure
812
+ api_type: :openai_azure, #Default type will be :openai (possible values are :openai, :openai_azure)
813
+ #If supplied :openai_azure then it is necessary to supply host
814
+ api_version: '2023-03-15-preview', # Default api version for :openai_azure
815
+ model: 'gpt-3.5-turbo',
816
+ smartbot_model: 'gpt-3.5-turbo'
817
+ },
818
+ # Optional. For DALL-E. If supplied it will be used instead of the ones defined for all open_ai services
819
+ dall_e: {
820
+ host: 'HOST',
821
+ access_token: 'OPENAI_ACCESS_TOKEN',
822
+ image_size: '256x256',
823
+ },
824
+ # Optional. For Whisper. If supplied it will be used instead of the ones defined for all open_ai services
825
+ whisper: {
826
+ host: 'HOST',
827
+ access_token: 'OPENAI_ACCESS_TOKEN',
828
+ model: 'whisper-1',
829
+ }
736
830
  }
737
831
  }
738
832
  ```
739
833
 
740
834
  Or if you want you can set your personal access token just to be used by you by calling on a DM with the SmartBot the command: `set personal settings ai.open_ai.access_token ACCESS_TOKEN`
741
- Also you can specify personal settings for `gpt_model`, `whisper_model` or `image_size`, instead of using the default values.
835
+ Also, you can specify personal settings for `host`, `ai.open_ai.chat_gpt.model`, `ai.open_ai.chat_gpt.smartbot_model`, `ai.open_ai.whisper.model` or `ai.open_ai.dall_e.image_size`, instead of using the default values.
836
+ For using different hosts or tokens for each service you can use the `chat_gpt`, `dall_e` or `whisper` keys.
742
837
 
743
838
  #### ChatGPT
839
+ > for all users
840
+
841
+ For a quick introduction play this video:
842
+ [![SmartBot ChatGPT](https://img.youtube.com/vi/zri_R6sLtBA/0.jpg)](https://www.youtube.com/watch?v=zri_R6sLtBA)
744
843
 
745
- `??`
746
844
  `?? PROMPT`
747
845
  `? PROMPT`
748
846
  Chat GPT will generate a response based on the PROMPT indicated.
@@ -751,9 +849,37 @@ You can share a message and use it as input for the supplied prompt.
751
849
 
752
850
  <img src="img/chat_gpt.png" width="650">
753
851
 
754
- <img src="img/chat_gpt_share.png" width="300">
852
+ <img src="img/chat_gpt_share.png" width="600">
853
+
854
+
855
+ When using ?? a temporary chatGPT session will be created. If you want to start a session with a given name use `chatGPT SESSION_NAME`. You can add also the description of the session by using `chatGPT SESSION_NAME "DESCRIPTION"`.
856
+ If you want to categorize your sessions you can use `chatGPT SESSION_NAME >TAG_NAME`.
857
+ You can supply also a specific GPT model to be used. `chatGPT SESSION_NAME MODEL_NAME`.
858
+ To get all prompts from a specific session name use `chatGPT get SESSION_NAME`.
859
+ To list all sessions you created use `chatGPT sessions`.
860
+ When starting a new session, if you ask SmartBot to answer on a Thread by using !! or ^, then it won't be necessary to send ? before the prompt. In this case, every single message you send will be considered a prompt to be treated. After 30 minutes of inactivity, SmartBot will stop listening to the thread. You will need to continue the session after that. If you want to avoid a message to be treated then start it with a hyphen '-'.
861
+ To add a collaborator when on a thread, you can use directly `add collaborator @USER`
862
+ If you include in the prompt `!URL` then it will download and use the content of the URL as input for the prompt.
863
+ When on a thread you can change the model to be used by sending `use model MODEL_NAME`. For a temporary session if you want to create the session with a specific model use `?? use model MODEL_NAME`. The model supplied can be a substring of the model name, SmartBot will try to find the model that matches the substring.
864
+
865
+ <img src="img/chat_gpt_session.png" width="650">
866
+
867
+ You can copy your session by using `chatGPT copy SESSION_NAME NEW_SESSION_NAME`.
868
+ To share your session with everyone use `chatGPT share SESSION_NAME`. Then the session will be available for everyone to use. If you prefer to share it with a specific channel use `chatGPT share SESSION_NAME #CHANNEL`. In that case, only the users on that channel will be able to use the session.
869
+ To list all public sessions call `chatGPT public sessions`. To list all shared sessions in a channel, from that channel call `chatGPT shared sessions`. You can also filter the sessions by tag, for example, `chatGPT public sessions >TAG_NAME`.
870
+ If you want to use any public or shared session, you can use `chatGPT use USER_NAME SESSION_NAME` or `chatGPT use USER_NAME SESSION_NAME NEW_SESSION_NAME`.
871
+ To remove any shared session from the list, call `chatGPT stop sharing SESSION_NAME` or `chatGPT stop sharing SESSION_NAME #CHANNEL`.
872
+
873
+ Play this video:
874
+ [![SmartBot ChatGPT Share Sessions](https://img.youtube.com/vi/Mnve3tnEd-8/0.jpg)](https://www.youtube.com/watch?v=Mnve3tnEd-8)
875
+
876
+ You can also use ChatGPT when creating REPLs. During the REPL session you can ask *ChatGPT* about the code or any other question. Just start the message with `?` and the Smart Bot will ask ChatGPT and will post the answer. Example: `? How to create a new customer?`. If you send just the question mark without a prompt then ChatGPT will suggest next code line. Example: `?`
877
+ To send the results of a *SmartBot command* as input for a *ChatGPT* session, use `COMMAND ?? PROMPT`. Example: `bot help ?? how can I use the time off commands`. If you are on a thread you can send more SmartBot commands to the same session by using `COMMAND ?? PROMPT`.
878
+
755
879
 
756
880
  #### Image Generation
881
+ > for all users
882
+
757
883
  `??i PROMPT`
758
884
  `?i PROMPT`
759
885
  `?ir`
@@ -764,6 +890,7 @@ if using `?ir` will generate a new image using the session prompts.
764
890
  <img src="img/image_generation.png" width="400">
765
891
 
766
892
  #### Image Variations
893
+ > for all users
767
894
 
768
895
  `?iv`
769
896
  `?ivNUMBER`
@@ -774,6 +901,7 @@ If an image is attached then it will generate temporary variations of the attach
774
901
  <img src="img/image_variations.png" width="400">
775
902
 
776
903
  #### Image Editing
904
+ > for all users
777
905
 
778
906
  `?ie PROMPT`
779
907
  It will edit the attached image with the supplied PROMPT. The supplied image needs to be an image with a transparent area.
@@ -782,6 +910,7 @@ The PROMPT need to explain the final result of the image.
782
910
  <img src="img/image_editing.png" width="400">
783
911
 
784
912
  #### Whisper
913
+ > for all users
785
914
 
786
915
  `?w PROMPT`
787
916
  `?w`
@@ -790,11 +919,71 @@ It will transcribe the audio file attached and perform the PROMPT indicated if s
790
919
  <img src="img/whisper.png" width="650">
791
920
 
792
921
  #### Models
922
+ > for all users
793
923
 
794
924
  `?m`
795
925
  `?m MODEL`
926
+ `chatgpt models`
796
927
  It will return the list of models available or the details of the model indicated.
797
928
 
929
+ ### Recap
930
+ > for all users
931
+
932
+ `recap`
933
+ `my recap`
934
+ `recap from YYYY/MM/DD`
935
+ `recap from YYYY/MM/DD to YYYY/MM/DD`
936
+ `recap YYYY`
937
+ `recap #CHANNEL`
938
+ `my recap #CHANNEL`
939
+ `recap from YYYY/MM/DD #CHANNEL`
940
+ `recap from YYYY/MM/DD to YYYY/MM/DD #CHANNEL`
941
+ `recap YYYY #CHANNEL`
942
+ It will show a recap of the channel. If channel not supplied, it will show the recap of the current channel.
943
+ If 'my' is added, it will show also a recap of your messages.
944
+ If only one date is added, it will show the recap from that day to 31st of December of that year.
945
+ If only one year is added, it will show the recap from 1st of January to 31st of December of that year.
946
+ Examples:
947
+ >**_`recap`_**
948
+ >**_`my recap`_**
949
+ >**_`recap 2023`_**
950
+ >**_`recap from 2023/07/01 to 2023/12/31 #sales`_**
951
+ >**_`recap 2022 #sales`_**
952
+
953
+ <img src="img/command_recap.png" width="250">
954
+
955
+ ### Summarize
956
+ > for all users
957
+
958
+ `summarize`
959
+ `summarize since YYYY/MM/DD`
960
+ `summarize #CHANNEL`
961
+ `summarize #CHANNEL since YYYY/MM/DD`
962
+ `summarize URL_THREAD`
963
+ It will summarize using ChatGPT the messages in the channel since the date specified.
964
+ If no date is specified it will summarize the last 30 days.
965
+ If time off added using Time Off command it will summarize since your last time off started.
966
+ If no channel is specified it will summarize the current channel.
967
+ If a thread URL is specified it will summarize the thread.
968
+ If the command is used in a thread it will summarize the thread.
969
+ Examples:
970
+ >**_`summarize`_**
971
+ >**_`summarize since 2024/01/22`_**
972
+ >**_`summarize #sales`_**
973
+ >**_`summarize #sales since 2024/01/22`_**
974
+ >**_`summarize https://yourcompany.slack.com/archives/C111JG4V4DZ/p1622549264010700`_**
975
+
976
+ <img src="img/command_summarize.png" width="500">
977
+
978
+ ### Personal Settings
979
+ On a DM with SmartBot you can call `set personal settings` command and supply your specific personal settings just for you. Then the command using those settings will be specific for you with the value indicated here.
980
+ Examples:
981
+ >**_`set personal settings ai.open_ai.access_token Axdd3SSccffddZZZDFFDxf7`_**
982
+ >**_`set personal settings ai.open_ai_chat_gpt.model gpt-4-turbo-preview`_**
983
+ >**_`set personal settings authorizations.confluence.host confluence.love.example.com`_**
984
+ >**_`set personal settings authorizations.confluence.authorization Bearer XDfjjdkAAAjjjdkkslsladjjjd`_**
985
+
986
+ Other commands: `delete personal settings SETTINGS_ID`, `get personal settings`, `get personal settings SETTINGS_ID`
798
987
 
799
988
  ### Tips
800
989
  > for admins
@@ -814,7 +1003,7 @@ When uploading a file the message added to 'Add a message about the file' will b
814
1003
  ```ruby
815
1004
  when /^do something with my file/i
816
1005
  if !files.nil? and files.size == 1 and files[0].filetype == 'yaml'
817
- require 'nice_http'
1006
+ require "nice_http"
818
1007
  http = NiceHttp.new(host: "https://files.slack.com", headers: { "Authorization" => "Bearer #{config.token}" })
819
1008
  res = http.get(files[0].url_private_download, save_data: './tmp/')
820
1009
  # if you want to directly access to the content use: `res.data`
data/img/chat_gpt.png ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/img/openai.png ADDED
Binary file
data/img/slack-300.png ADDED
Binary file
data/img/slack.png ADDED
Binary file
Binary file
Binary file
Binary file
data/img/smart-bot.png ADDED
Binary file
data/img/whisper.png ADDED
Binary file