Delete All Canvas Conversations
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
So the school district I work for encountered a problem with students having unnecessary conversations in Canvas using the Inbox. The first thing we did was disable the permission 'Send messages to individual course members' for student, this prevented students from creating new conversations and resolved half the problem. After this the task moved to cleaning up all of the conversations students we're having that may or may not have been inappropriate. I took to the Canvas community where I found multiple discussions regarding this issue and multiple failed feature requests. I thought well now these conversations will need to be deleted manually, something I did not want to do for our 15,000+ students in Canvas. I also thought that is crazy, I will not go through manually and delete all these conversations, i'll find a way to do this so my interaction is minimal. Well I have now found that way and want to provide it to everyone so nobody else has to reinvent the wheel since i have already built it.
Attached you will find a sample file called canvasUserArray.txt, and inbox_Cleanup.ps1 Follow the instructions below and you should be able to clear out all or simply targeted Canvas Inbox conversations.
- Generate an access token in Canvas.
- Log In > Account > Settings > + New Access Token
- Enter a purpose and set an expiration date if you like.
- Copy the token from the Access Token Details and save a it somewhere safe.
- Setup the canvasUserArray.txt file
- Generated a list of id's by using the Canvas Provisioning report for all users
- Copy the USER_ID column from the provisioning report
- Paste them in a text file
- Save the file as canvasUserArray.txt to C:\Temp on the computer you will run the Powershell script from.
- Modify the inbox_Cleanup.ps1 Powershell script. (This can look overwhelming but I will direct you to what you need to change.)
- Open the script in a text editor
- Line 10 - copy your access token you generated in step 1 and replace the words AccessToken with the token, make sure to leave the double quotes
- Line 13 - the portion of the url before /api needs to be replaced with your Canvas url, or if yours is setup like mine you can simply replace 'institution' with whatever is in your url
- Line 17 - modify the url in the same way as you did for line 12
- Notes about this method
- It does not matter what the type of the conversation is, ie. "unread","starred","archived","sent"
- If you wish to output the list of user/conversations or delete statements remove the #'s at the beginning of line 16 and directly before the | (pipe) on line 18
- Might need to be ran multiple times
- Through my testing I had a few users who had 100+ conversations and therefore I had to run the script numerous times in order to catch all conversations.
- A file called processDateTimeLog.txt will be created in C:\Temp\ which will display the time the process took to run, the file is appended to each time the process runs.
- Optional features included in my script.
- I have built a targeted method into this script if you wish to only delete specific conversation types
- Open the script in a text editor
- Line 4 - remove the # at the beginning of the line
- You can remove scope types from the array built here, simply delete the type including the double quotes and comma if needed.
- Line 11 - type <#
- Line 19 - type #>
- Line 20 - delete <#
- Line 31 - delete #>
- If you wish to output the list of user/conversations or delete statements remove the #'s at the beginning of line 28 and directly before the | (pipe) on line 30
- Save the script
- # and <# #> are used to comment out text in the script, # is used for a single line, anything on the line following the # will not be read as part of the script, <# #> are used for multi line comments, anything between <# and #> will not be read as part of the script.
- I have built a targeted method into this script if you wish to only delete specific conversation types
- To run the script you can either copy the code from a text editor and paste it into a Powershell window or double click the file after it has been modified.
I'm no Powershell Expert but this is working for me so I wanted to share. If you need any help you can let me know, but as I stated, i'm not expert so i can't guarantee i'll be able to assist. Also if anyone is an expert and could provide insight for improvement on the script that would be awesome.
Good luck!
Ben Hudson
Application Developer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.