Skip to content

forcedotcom/sf-skills / skills/service-agentforce-contact-center-coordinate

service-agentforce-contact-center-coordinate

Verified

Coordinates end-to-end setup of an Agentforce Contact Center voice channel: gathers country and phone-number-type selections, procures a chosen number, resolves its CommunicationChannelLine, verifies the number is live, and creates an active PstnVoice MessagingChannel. The user picks the routing model: Omni Queue (route to the contact center queue) or Omni Flow (route to an Agentforce agent, creating or reusing the agent plus its routing flows). Use when the user asks to set up an Agentforce Contact Center, provision a contact center phone number and voice channel together, or put an Agentforce agent on native voice. TRIGGER when the user says set up agentforce contact center, configure contact center voice, or create a voice channel with omni flow and an agentforce agent. DO NOT TRIGGER when only wiring an existing channel to an existing agent with no number to procure, or creating a non-voice messaging channel.

scripts/lib.sh

View on GitHub
#!/usr/bin/env bash
# Shared constants for the Agentforce Contact Center coordination scripts.
# Not invoked directly — sourced by the other scripts.
#
# All API calls go through `sf api request rest`, which uses the CLI's stored
# session for --target-org. Never extract the access token from `sf org display`.

set -euo pipefail

API_VERSION="v68.0"
NM_BASE="services/data/${API_VERSION}/connect/number-management/v1"

# URL-encode a value's spaces (sufficient for country/phoneType query params).
urlenc_spaces() { printf '%s' "${1// /%20}"; }

# Percent-encode a full value for safe use as a URL query-parameter value: only
# the RFC 3986 unreserved set stays literal, everything else becomes %XX. Needed
# for free-text values (e.g. a user-supplied area code / prefix) so reserved
# characters like & or = can't inject extra query parameters into the request.
urlenc() {
  local s="$1" i c out=""
  for (( i=0; i<${#s}; i++ )); do
    c="${s:i:1}"
    case "$c" in
      [a-zA-Z0-9.~_-]) out+="$c" ;;
      *) printf -v c '%%%02X' "'$c"; out+="$c" ;;
    esac
  done
  printf '%s' "$out"
}

# XML-escape a value for safe interpolation into flow-template stringValue/label nodes.
# Free-text org data (queue names, agent labels) can contain &, <, >, ", ' — unescaped
# they produce malformed XML and an opaque `sf project deploy start` parse error.
# Escape & first so the entities emitted by the later rules aren't double-escaped.
xml_escape() { printf '%s' "$1" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&apos;/g'; }

# Scaffold a minimal SFDX project at <dir> if one isn't already there. The Omni Flow path
# generates an agent authoring bundle and deploys RoutingFlows, both of which need a project
# context. sourceApiVersion is pinned to API_VERSION for consistency (v68).
ensure_sfdx_project() {
  local dir="$1"
  mkdir -p "$dir/force-app/main/default"
  if [[ ! -f "$dir/sfdx-project.json" ]]; then
    printf '%s\n' "{\"packageDirectories\":[{\"path\":\"force-app\",\"default\":true}],\"namespace\":\"\",\"sfdcLoginUrl\":\"https://login.salesforce.com\",\"sourceApiVersion\":\"${API_VERSION#v}\"}" \
      > "$dir/sfdx-project.json"
  fi
}

# Render a token template to stdout, replacing every {{KEY}} with the paired value.
# Usage: render_template <template-file> KEY=VALUE [KEY=VALUE ...]
# Plain string replacement (no regex) so XML/URL values pass through unchanged.
render_template() {
  local tmpl="$1"; shift
  local content pair key val
  content="$(<"$tmpl")"
  for pair in "$@"; do
    key="${pair%%=*}"; val="${pair#*=}"
    content="${content//\{\{${key}\}\}/${val}}"
  done
  printf '%s\n' "$content"
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall