How to Automate the Creation of HipChat Users and Room Assignments from Data in Another System
Recipe overview
This recipe provides step-by-step instructions on how to automatically add new employees (from an example HR Data Mart system) as new users within HipChat with automated room assignments based on the new employee's department.
It will take you approximately 7-8 minutes to complete this recipe.
Recipe level
Ingredients
Preparation
Install the latest downloadable HipChat CLI Client on your computer.
If you have not done so already, follow all of the CLI installation instructions including the steps marked optional.
Create rooms in HipChat for your team, if you have not done so already.
Open a command window you'll use to execute CLI commands.
Steps
Get the data
Estimated Time: 2-3 min
For each new employee, two HipChat CLI actions must be executed to accomplish this purpose: The @mention name and email address must be unique across all groups in the HipChat instance. You need to create a comma-separated values file (.CSV) similar to the one shown on the right, as this provides an easy way to feed data to the CLI client without worrying about getting it into the correct syntax:
You can create this file manually, from an Excel spreadsheet, or by saving the output from a database query. The value should be enclosed within double quotes if any field contains a line break, double-quote or comma. The resulting file should be in plain text format, named newhires.csv. |
newhires.csvaction,name,email,title,mentionName,room createUser,Hank Johnson,hank@examplegear.com,Engineer,hjohnson,"Examplegearinc-engineering" createUser,Jim Robertson,jim@examplegear.com,Engineer,jrobertson,"Examplegearinc-engineering" addRoomMembers,Hank Johnson,,,,"Examplegearinc-engineering" addRoomMembers,Jim Robertson,,,,"Examplegearinc-engineering" | |
Create CLI command
Estimated Time: 1 min
Use the command shown on the right to invoke the HipChat CLI client to process the data from your CSV file.
| Example command: hipchat --action runFromCsv --file newhires.csv --continue | |
Execute CLI command
Estimated Time: 1 min
In your command window, type the command from the previous step and press Enter. The command will run, showing the result of executing each action in newhires.csv. | Example output: Run: --mentionName "hjohnson" --name "Hank Johnson" --action "createUser" --title "Engineer" --email "hank@examplegear.com" --room "Examplegearinc-engineering" User created with id: 1928057 Run: --mentionName "jrobertson" --name "Jim Robertson" --action "createUser" --title "Engineer" --email "jim@examplegear.com" --room "Examplegearinc-engineering" User created with id: 1928058 Run: --mentionName "" --name "Hank Johnson" --action "addRoomMembers" --title "" --email "" --room "Examplegearinc-engineering" 1 members added to room. Run: --mentionName "" --name "Jim Robertson" --action "addRoomMembers" --title "" --email "" --room "Examplegearinc-engineering" 1 members added to room. Run completed successfully. 4 actions were successful from file: /Users/jasmine/Documents/CLI/newhires.csv | |
Tell the new employees
Estimated Time: 3 min
Users added to HipChat via the HipChat CLI client will receive no notification email from HipChat. Therefore, you need to do the following:
From that point on, they can go into the room and start chatting! |
| |
Create a reusable CLI script
OPTIONAL Estimated Time: 2 min
If you'd like to save your CLI command for later reuse, you can save it as a CLI script file. Using an editor capable of producing a plain text file, such as Notepad (Windows) or TextEdit (Mac), create a script file named:
Save it in the same folder to which you installed the HipChat CLI client and make sure it has permissions so that you can read, write and execute it. Follow these steps in your command window to execute the script file you just created:
The script will run, showing the result of executing each action in newhires.csv. | Contents of example CLI script file: hipchat --action runFromCsv --file newhires.csv --continue Command to execute reusable script file: add2room | |