# User experience for imported users?

**URL:** https://meta.discourse.org/t/user-experience-for-imported-users/141554
**Category:** Migration
**Created:** [February 13, 2020, 11:05pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554 "2020-02-13T23:05:35Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [February 13, 2020, 11:05pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/1 "2020-02-13T23:05:36Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 13, 2020, 11:17pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/2 "2020-02-13T23:17:58Z")

</div>

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)](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.

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [February 13, 2020, 11:39pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/3 "2020-02-13T23:39:52Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 13, 2020, 11:57pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/4 "2020-02-13T23:57:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 5, 2020, 11:02pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/5 "2020-03-05T23:02:55Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [March 5, 2020, 11:30pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/6 "2020-03-05T23:30:04Z")

</div>

🤷‍♂️

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

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 5, 2020, 11:52pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/7 "2020-03-05T23:52:11Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [March 6, 2020, 4:04am UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/8 "2020-03-06T04:04:54Z")

</div>

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

```bash
ssh ....
cd /var/discourse
./launcher enter app
rails c

```

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 6, 2020, 3:13pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/9 "2020-03-06T15:13:05Z")

</div>

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. 🙂

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 6, 2020, 3:20pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/10 "2020-03-06T15:20:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 17, 2020, 3:19pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/11 "2020-03-17T15:19:27Z")

</div>

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?

 ![image](https://global.discourse-cdn.com/meta/original/3X/6/8/68dbe14a6cdaffeac0667fd0554f67fab88ea82a.png)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 17, 2020, 4:40pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/12 "2020-03-17T16:40:42Z")

</div>

> [@adamengst](#):
>
> Were the users created?

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.

> [@adamengst](#):
>
> Since retries are failing, should I just delete these errors and move on?

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.

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 17, 2020, 9:37pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/13 "2020-03-17T21:37:27Z")

</div>

> [@adamengst](#):
>
> Were the users created?

> [@pfaffman](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![adamengst](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adamengst/32/116607_2.png) [@adamengst](https://meta.discourse.org/u/adamengst)
#### Post date: [March 19, 2020, 7:06pm UTC](https://meta.discourse.org/t/user-experience-for-imported-users/141554/14 "2020-03-19T19:06:51Z")

</div>

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.
