ChiefOnboarding
ChiefOnboarding copied to clipboard
ChiefOnboarding v2.0 release
Alright, so everything is almost ready to be pushed to master. The code has been tested quite well (and has a 93% test coverage), though it could still use some more test cases, especially with the custom integrations and perhaps on the frontend.
If all goes well, then everything will be merged on Thursday!
To summarize (and keep track of what needs to be done):
- Completely new look
- Moved from SPA back to MPA (dropped almost all javascript requirements)
- Support for custom integrations and webhooks created by you (https://integrations.chiefonboarding.com / https://github.com/chiefonboarding/ChiefOnboarding/blob/v2.0/docs/Integrations.md)!
- Sequence timed based triggers can now be triggered at a custom time (used to be always at 8 am)
- Slack doesn't need to depend on webhooks anymore - websocket is now supported as well (so you can also use it without having a public access point).
- Notifications on both the new hire and admin side on various actions
- Change channel where bot sends messages to
- Change admin to manager and vise versa
- Change email template
- Assign admin tasks in sequence to admin/manager instead of a specific person
- Docs have been updated and added into the main repository on the v2.0 branch (not live on a website yet, but see the
docs
folder)
BREAKING CHANGES:
- Scheduled access items that have been scheduled on the old version will not be executed anymore - table is dropped and functionality has been replaced
- ~API is currently dropped, but will be back later.~ It's back, but changes will be necessary.
- Some urls will not be accessible (like preboarding links). I am not setting up a redirect for this. These will return 404.
- Slack account creation will temporarily be removed. Record will still be in the database and will be available for use when I create this integration again.
- Google account creation will be temporarily removed. Record will still be in the database and will be available for use when I create this integration again. Will be back in v2.1. You could also remove this integration before migrating if you want to.
- Selectboxes have been dropped temporarily from forms. Those will be gone after migration.
- You can update Slack to use the internal websocket instead of the HTTPS calls webhooks. That way, you remove one open endpoint (technically, you could use the app now with Slack behind a VPN). Webhooks is the default.
- SLACK BOT: Under "Interactivity & Shortcuts" in the config of your bot (https://api.slack.com/apps), change "callback" to "bot" in the URL. It should now be the same URL as you have under "Event Subscriptions".
- Buttons posted in Slack before this migrations might become invalid.
Implemented for release:
- [x] #147
- [x] #144
- [x] #141 (general idea to webhooks / custom integrations)
- [x] #129
- [x] #128
- [x] #126
- [x] #124
- [x] #123
- [x] #122
- [x] #120
- [x] #104 (this shouldn't be a problem anymore as it's not decoupled anymore)
- [x] #92 (message that uploading is disabled)
- [x] #27
- [x] #24
- [x] #22 (general option to send message after integration/webhook trigger)
- [x] #21
- [x] #15
- [x] #13
- [x] #12
- [x] #5
- [x] Update Slack docs (new manifest)
- [x] Add other languages back (hiring people to make the translations)
- [x] Bug bash - Wanna join? Email me and I will set up an instance for you to play around with.
- [x] Test database migrations. Lots of data has been moved around, double check that everything is still correct after deployment of new version.
To be done right after release:
- [x] #142
- [x] #140 (will create this integration when I have a minute - if not too complicated)
- [ ] #138 (this has been removed - need to recreate a legacy version and enterprise version)
Can't merge it yet. There are a few bugs that I need to solve and I am missing the German translations (will be created and merged in the next few days).
@GDay wanted to see how this was going. We are thinking about trying this for our company but we have been waiting for v2 and are not sure when an eta was. Thank
@woakes070048 Yeah, I am doing the best I can. There are a few bugs left in the sequences that I need to fix. The rest is working fine. Should be ready for production early next week.
@woakes070048 This will be merged on Thursday.
@GDay thanks I look forward to trying this out.
Everyone will be F5'ing today :D
Haha! Will take a few more hours. I am currently running a few more live tests and fixing some minor bugs here and there.
We all really appreciate it @GDay <3
Well, this was a long day. So, I have just merged everything into master. I did a lot of testing today and most things seem to work fine, but will do more battle-testing in the next few days. I have one issue still standing where courses/resources don't update the modal when it's opened in Slack. It works locally, but not on my staging server, not sure what's going on there, but will give that another go tomorrow.
As always: use at your own risk and create a backup before updating. There are a lot of migrations that will be ran.
I have also updated the main post above with all the breaking change that I noticed.
One of the main features for this release is the webhook/integration option. You can now create your own integrations, like this one: https://integrations.chiefonboarding.com/d/1-asana-account-creation. This can then be used in a sequence. I will be creating more of those integrations with different services. Docs: https://github.com/chiefonboarding/ChiefOnboarding/blob/master/docs/Integrations.md
For some reason the docs workflow crashed, so the site is not up to date yet, but will fix that tomorrow.
Please report any bugs, so I can fix them :)
Hey @GDay loving v2! It looks so gorgeous!
Ran into a slight issue with the slackbot, Ive updated the url as suggested above, but the bot itself has completely stopped working :D
I am going to create a new test env so I can see if its just that particular bot
@MuratDoganer Oh, that's not good. Are you using the web socket or not?
If you are not using the socket, then see this (as mentioned above):
You can update Slack to use the internal websocket instead of the HTTPS calls webhooks. That way, you remove one open endpoint (technically, you could use the app now with Slack behind a VPN). Websocket is the default. If you don't want to use the websocket, then you will have to add SLACK_USE_SOCKET to False in your environment variables. It will then fall back to the "old" url and webhooks. It's important that you set this variable AFTER all migrations have ran.
If you are using the socket, then you will need to create an app token, see docs: https://github.com/chiefonboarding/ChiefOnboarding/blob/master/docs/Deployment.md#slack-bot
@GDay Yup done those!
I've just deployed with heroku to test a new integration and it worked fine, so maybe it had some trouble migrating?
@MuratDoganer Strange, in your Heroku logs, does it hit the webhook url when you write something to the bot? That should return a 200 status code.
@GDay Interesting, no it does not. Nothing comes up in the logs at all
I did use the new token under the SLACK_APP_TOKEN env, sockets are on, maybe ill try falling back to the old way and see what happens
Wait, you are currently using websockets, is that right?
If that's the case, then you should not have the SLACK_USE_SOCKET
environment variable. It's on by default, so you don't need it.
You will also need:
SLACK_APP_TOKEN
and SLACK_BOT_TOKEN
as environment variables.
But yeah, perhaps good to fall back to webhooks for now until we get down to the issue.
Ah I was missing the first bit of the SLACK_BOT_TOKEN
, i've added it in and I am seeing activity from the bot now in the logs
However trying to run any kind of command leads to this:
2022-07-08T16:10:16.942420+00:00 app[worker.1]: Traceback (most recent call last):
2022-07-08T16:10:16.942421+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/slack_sdk/socket_mode/client.py", line 155, in process_messages```
Hmm.. strange, I see it now as well on Heroku. However, the bot still seems to function fine. I am looking into this.
So I've reverted back to the old urls, still no slackbot responses but, i do now see the correct message in the logs
[08/Jul/2022:16:22:10 +0000] "POST /api/slack/bot HTTP/1.1" 200 0 "-" "Slackbot 1.0 (+https://api.slack.com/robots)"
Hmm... could you run this please? Go into heroku and click on "more" and then "run console". Then type in "bash" and hit "run", Then do "cd back" and then run "python manage.py shell". That will get us a python shell.
Then type:
from admin.integrations.models import Integration
print(Integration.objects.filter(integration=0).count())
If that shows anything more than 1, then that might be the issue. It will always take the first one. If you have tried to add the slack bot multiple times in the past, then the first one might have an old/invalid token.
Yes you are correct, I did indeed get back 1
If it got back 1, then that's not the issue. Very strange. I can't seem to replicate it on my side. It looks like Slack recognizes that you sent a message, but for some reason refuses to send one back.
Let's see if you can send a message manually.
Go back into the shell again with the instructions above. Then get your slack user id:
from users.models import User
u = User.objects.get(email="[email protected]")
print(u.slack_user_id)
Send a slack message:
from slack_bot.utils import Slack
Slack().send_message(channel=u.slack_user_id, text="test message")
Yeah nothing is coming through, no error message either!
But in the other environment (from new) its working fine, so weird
Hmm... I have found an issue with websockets that may be why it wasn't responding back to you. I have just merged a PR for that. Perhaps you could try it again with the new update?
Also, is it just messages that don't work, or does it also not react to buttons?
Oh, also, it does actually save error messages when sending message (but it doesn't display those yet). It saves notifications. You can get the last one with (within shell):
from organization.models import Notification
note = Notification.objects.filter(notification_type="failed_send_slack_message").last()
print(note.description)
Alright, so at least on Heroku (not sure about other platforms), the websocket requests are incredibly unstable. I am constantly getting requests that take way too long and therefore timeout/crash.
The previous error:
File "/app/.heroku/python/lib/python3.9/site-packages/slack_sdk/socket_mode/client.py", line 155, in process_messages
seems to be related to the python version. With Python 3.8, it works fine. Both 3.9 and 3.10 show the error. Could also be related to Heroku, I am not entirely sure.
On local host (for development), I have never gotten them - it's always been fine. I am not sure why it's slow, perhaps Heroku doesn't like the threading that we need to do to keep the websocket up and alive. I have now set SLACK_USE_SOCKET
to False
by default and I would recommend using the webhooks for now.
If you want to do a query to Slack directly (using their library), then you can do this (through shell again):
from admin.integrations.models import Integration
from slack_bolt import App as SlackBoltApp
from users.models import User
u = User.objects.get(email="[email protected]")
integration = Integration.objects.filter(integration=0).first()
client = slack_sdk.WebClient(token=integration.token)
client.chat_postMessage(channel=u.slack_user_id, text="Whatever you want to say")
If it errors, Slack will raise an exception that will be printed out in your console.
Okay, getting this:
redirect_uri did not match any configured URIs. Passed URI: https://mycompaniesurlforchief.com
In your Slack app settings: https://api.slack.com/apps.
Go to "OAuth & Permissions" and change the "redirect url" to https://mycompaniesurlforchief.com/admin/integrations/slack
(swap the domain with yours). You probably have "api" instead of "admin" in the url right now.
Not sure why you are getting that though, because that url is not used for slack messages, I think.
Yeah, looking through the code, that's not being used with Slack calls. You got that error when you sent a message to the bot through the code above?
I dont know why, but that did fix it
I can only speculate it wasnt authorising properly?
Yeah that was the error message I got when I used the code above.
It's odd, but changing /api/
to /admin/
like you suggested worked, I am now getting messages in Slack again