User experience for imported users?

I’m looking at importing some 600 email addresses from a mailing list into Discourse, with the goal of having everyone automatically set to watch an Announcements category that will essentially serve the purpose of replicating the primary function of the mailing list.

It’s my understanding that as part of the import process, we (I understand there are scripts involved, and I’ll need my developer to do this) can force all the imported people to be Watching the Announcements category, such that they’ll definitely receive email for every post (unless they stop watching it manually). Is that true?

What’s less clear to me is what the user experience will be for the imported users. They’ll each have an account, but I presume they won’t be able to login until they set a password, and the first time they visit the site, Discourse will ask them to do so. Correct?

And what if they never set a password at all? (Most don’t realize that they have Mailman accounts now; so there was pushback about having to have another account. Sigh.) If someone never visits the site and never logs in, will they still receive email for topics and posts in the Announcements category?

For anyone who has done this, what sort of support issues did you have to deal with after the import?

Thanks!

1 Like

If you already have a transactional relationship with these folks, i.e., you’re moving them to a new platform, there are ways to shortcut the user creation process. It’s for more advanced admins, but here are some command line (rails console) ideas that could work:

u = User.new({username: 'testuser', email: 'testuser@example.com', name: 'Test User', trust_level: 2, password: SecureRandom.hex});
u.activate();
t = u.email_tokens.create(email: u.email);
Jobs.enqueue(:critical_user_email, type: :account_created, user_id: u.id, email_token: t.token);

From my experience, this will create the new user with the details you provide, activate their account so they can receive email, and then send them an email letting them know that an account has been created for them on your Discourse site, and gives them a link to set up their account:

A new account was created for you at Your Discourse Site Name

Click the following link to choose a password for your new account:
https://discourse.example.org/u/password-reset/(randomdigits)

You would need to set up your Announcements category so that all new users are automatically Watching it, which is a site setting.

3 Likes

Thanks! That seems relatively straightforward (and yes, these are all users on a list I manage and that I’m trying to move off Mailman).

Do you know what will happen if they never set up their account, in terms of them receiving email to the auto-Watching Announcements category?

There are smarter people around here than me on this topic, but I think that because you run the u.activate(); command, they’re already fully activated and the only thing they’re doing through the email is changing their password from the initial random string that nobody knows.

There is a notion that inactive users eventually stop getting emails, but I’m not sure if that would come into play here for “auto-watched” categories, I have only really thought of it in terms of the digest/summary recipients. Hopefully someone else can chime on that answer.

4 Likes

Another quick question on imports. Do you know what will happen if you try to import an email address that’s already assigned to a user in the system? Will it just be skipped?

:man_shrugging:

I’d just give it a test with a throw-away address to find out.

I was afraid you’d say that. The Rails console approach proved vastly beyond my admin capabilities (Rails wasn’t even installed on our VPS, and I couldn’t see how I’d import 600 addresses that way anyway), so I’m having to bring in our developer. I’ll ask him to check.

You can get to the rails console on your self hosted Discourse site like this:

ssh ....
cd /var/discourse
./launcher enter app
rails c
2 Likes

Thanks! I had to add sudu su before the third line to get permission to connect to the docker daemon, but then it worked and I was able to execute the lines in the Rails script above and create a test user. Yay!

How would this script expand to work with a list of 600 email addresses though? Running it 600 times seems… tedious. :slight_smile:

1 Like

You’d generate a script that either had that line for the 600 users or stick the data into some data structure and loop through it.

3 Likes

Since no one here had any Ruby experience, we opted for creating a large file of all the commands and pasting them into the Rails console. Seems to work except that there are now four errors in Sidekiq (out of the first 50 test imports), and I don’t know what to do with them or what they mean. Were the users created? Did they just not receive the welcome email? Since retries are failing, should I just delete these errors and move on?

That would be a good thing for you to find out.

It’s hard for me to imagine how the user_id would be invalid.

Probably so, but you’ll want to figure out which users failed and why. Were there errors when you pasted the commands? If you can’t find that out, you’ll need to look at the users that exist and the ones that you expect to exist and see what the difference is.

If you don’t have easy means to scroll back through the stuff, you should work in smaller batches so that you can check on their progress more easily.

3 Likes

I wasn’t alerted about this until quite a bit later, so there was no way to go back. It’s possible these errors are happening when an imported email address already exists in the system—I can test that. All the users I expected to have created were created.

But what I can’t figure out is if there’s any connection between the information in this screenshot and anything I could look up in Discourse. Are email_tokens something that can be linked back to any other information?

Sounds like I’ll just keep doing this in small batches and see if I can attach an error to one of these messages.

1 Like

Turns out these errors were generated every time there was an error in the import, things like usernames over 20 character, or two special characters in a row in a username, or possibly the email already being in use (I saw inconsistent results with that one). I just fixed each problem and moved on, and deleted all the errors from Sidekiq at the end.

2 Likes