forcedotcom/sf-skills / plugins/builder/service-omni/skills/service-omni-agent-users-create
service-omni-agent-users-create
VerifiedCreate reusable agent users for Omni-Channel setup and routing validation. TRIGGER when users ask to create Omni agents, provision Omni test users, seed sandbox users for routing, create Omni-Channel routing agents, or repair missing demo agents. DO NOT TRIGGER for queue membership, permission-set assignment, or supervisor-user creation.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.6 KB |
| assets/create-users.apex.template | other | 3.2 KB |
| references/apex-patterns.md | markdown | 8.8 KB |
| references/apex-template-notes.md | markdown | 1.7 KB |
| scripts/detect-and-create.shexecutable | script | 8.2 KB |
| scripts/detect-existing.shexecutable | script | 5.1 KB |
| scripts/run-create.shexecutable | script | 15.7 KB |
| scripts/tests/test_user_create_security.py | script | 8.5 KB |
assets/create-users.apex.template
View on GitHub// service-omni-agent-users-create - Anonymous Apex asset template. Tokens __COUNT__/__PROFILE_ID__/__SUFFIX__ resolved by run-create.sh. Idempotency, password/TraceFlag security note, output contract: references/apex-template-notes.md.
Integer requested = __COUNT__;
String profileId = '__PROFILE_ID__';
String suffix = '__SUFFIX__';
Map<String, Integer> expectedByUsername = new Map<String, Integer>();
for (Integer i = 1; i <= requested; i++) {
expectedByUsername.put('agent' + i + '.' + suffix + '@example.com', i);
}
Set<String> existingUsernames = new Set<String>();
for (User u : [SELECT Username FROM User WHERE Username IN :expectedByUsername.keySet()]) {
existingUsernames.add(u.Username.toLowerCase());
}
List<User> toInsert = new List<User>();
for (Integer i = 1; i <= requested; i++) {
String uname = 'agent' + i + '.' + suffix + '@example.com';
if (existingUsernames.contains(uname.toLowerCase())) {
continue;
}
// Alias must be <= 8 chars - 'omag' (4) + index + trailing suffix chars.
String aliasStr;
if (i < 10) {
aliasStr = 'omag' + i + suffix.substring(suffix.length() - 3);
} else {
aliasStr = 'omag' + i + suffix.substring(suffix.length() - 2);
}
User u = new User(
FirstName = 'Omni',
LastName = 'Agent' + i,
Email = uname,
Username = uname,
Alias = aliasStr,
ProfileId = profileId,
IsActive = true,
// Service Cloud feature license - required for the user to actually go online in
// Omni-Channel and to hold Omni permissions. Only allowed on user licenses that
// support it (e.g. Salesforce); the try/catch below strips it and retries when the
// profile's user license rejects it (e.g. the limited "Service Cloud" user license).
UserPermissionsSupportUser = true,
TimeZoneSidKey = 'America/Los_Angeles',
LocaleSidKey = 'en_US',
EmailEncodingKey = 'UTF-8',
LanguageLocaleKey = 'en_US'
);
toInsert.add(u);
}
if (toInsert.isEmpty()) {
System.debug('AGENT_USERS_ALL_EXIST - no inserts required');
return;
}
try {
insert toInsert;
System.debug('AGENT_USERS_SERVICE_CLOUD_FEATURE|enabled');
} catch (DmlException e) {
// The user license behind this profile does not allow the Service Cloud feature.
// Fall back to creating the users without it so the skill still provisions them; the
// operator must move them to a Salesforce license + Service Cloud feature for full Omni.
if (e.getMessage() != null && e.getMessage().contains('Service Cloud User')) {
for (User u : toInsert) { u.UserPermissionsSupportUser = false; }
insert toInsert;
System.debug('AGENT_USERS_SERVICE_CLOUD_FEATURE|skipped_license_not_allowed');
} else {
throw e;
}
}
// Emit machine-parseable lines. No password field - passwords are set by a separate
// `System.setPassword` Apex submission on the CLI side (run-create.sh), whose source
// Salesforce does not persist to any queryable ApexLog.
for (User u : toInsert) {
System.debug('AGENT_USER_CREATED|' + u.Id + '|' + u.Username + '|' + u.Email);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |