Skip to content

forcedotcom/sf-skills / skills/sales-agentforce-pipeline-management-configure

sales-agentforce-pipeline-management-configure

Verified

Use to configure, set up, or repair the Sales Management agent and Agentforce Pipeline Management in a Salesforce org. Automates metadata creation for flows, prompt templates, permission sets, and data source configuration. TRIGGER when: user wants to enable Pipeline Management, configure Sales pipeline features, set up the Sales Management agent for opportunity field updates (including autonomous updates), connect enabled data sources like Einstein Conversation Insights or Einstein Activity Capture, customize opportunity stage descriptions, configure post-meeting suggestions, verify or audit configuration status, fix partially configured orgs, or troubleshoot Pipeline Management metadata issues. DO NOT TRIGGER when: user wants to build a custom agent (use agentforce-generate), configure general Agentforce tracing (use platform-tracing-agentforce-configure), work with non-Sales agents, or enable Einstein Conversation Insights or Einstein Activity Capture from scratch (provisioning is out of scope).

FileKindSize
SKILL.mdskill md29.0 KB
assets/field-completion-template.genAiPromptTemplate-meta.xmlconfig8.6 KB
assets/pipeline_management_flow.flow-meta.xmlconfig22.9 KB
assets/sales_management_agent.agentother211.7 KB
assets/sales_management_agent.bundle-meta.xmlconfig163 B
assets/sfdx-project.jsonconfig254 B
assets/stage-descriptions/bant.txtmarkdown2.7 KB
assets/stage-descriptions/meddic.txtmarkdown2.9 KB
assets/stage-descriptions/spiced.txtmarkdown2.9 KB
examples/custom-prompt-instructions.mdmarkdown10.0 KB
references/admin-communication.mdmarkdown14.6 KB
references/agent-creation.mdmarkdown22.5 KB
references/auth-and-cli.mdmarkdown6.7 KB
references/automation-matrix.mdmarkdown2.2 KB
references/autonomous-updates.mdmarkdown8.4 KB
references/canonical-agent-path.mdmarkdown6.9 KB
references/data-sources.mdmarkdown6.6 KB
references/field-completion-prompt-template.mdmarkdown6.4 KB
references/field-completion-prompts.mdmarkdown10.4 KB
references/flags.mdmarkdown3.2 KB
references/flow-clone-from-template.mdmarkdown19.5 KB
references/metadata-inventory.mdmarkdown17.1 KB
references/opportunity-stages.mdmarkdown11.9 KB
references/repair-diagnostics.mdmarkdown14.1 KB
references/setup-order.mdmarkdown12.6 KB
references/soap-api-enablement.mdmarkdown21.7 KB
scripts/CHANGES.mdmarkdown5.6 KB
scripts/README.mdmarkdown3.1 KB
scripts/add-field-suggestion.shexecutablescript35.5 KB
scripts/create-agent.shexecutablescript13.2 KB
scripts/create-flow.shexecutablescript8.5 KB
scripts/define-agent-access.shexecutablescript21.2 KB
scripts/deploy-settings.shexecutablescript1.9 KB
scripts/enable-deal-agent.shexecutablescript10.0 KB
scripts/enable-prerequisites.shexecutablescript22.9 KB
scripts/flow-debug-and-verify.shexecutablescript18.4 KB
scripts/retrieve-settings.shexecutablescript5.7 KB
scripts/setup-all.shscript146.6 KB
scripts/shared/agent-bundle-publish.shscript6.7 KB
scripts/shared/agent-detection.shscript9.7 KB
scripts/shared/flow-builder.shscript9.5 KB
scripts/shared/psg.shscript1.9 KB
scripts/shared/soap.shscript5.6 KB
scripts/shared/stage-descriptions.shscript23.3 KB
scripts/shared/test-opp.shscript9.6 KB
scripts/verify-all.shexecutablescript26.0 KB
scripts/verify-prompt-generation.shexecutablescript13.8 KB

scripts/enable-deal-agent.sh

View on GitHub
#!/bin/bash

# Enable Pipeline Management (SalesDealAgentSettings) via SOAP API
# Usage: ./enable-deal-agent.sh <org-alias>

set -euo pipefail

# sf CLI can emit ANSI color codes inside --json stdout, breaking jq parsing.
# 2>/dev/null only strips stderr; these env vars are the reliable fix (see PM notes).
export NO_COLOR=1
export FORCE_COLOR=0

ORG_ALIAS="${1:-}"

if [[ -z "$ORG_ALIAS" ]]; then
  echo "❌ Error: Missing org alias"
  echo "Usage: $0 <org-alias>"
  exit 1
fi

echo "🚀 Enabling Pipeline Management for org: $ORG_ALIAS"
echo ""

# Get org details
ORG_INFO=$(sf org display --target-org "$ORG_ALIAS" --json 2>/dev/null)
ORG_ID=$(echo "$ORG_INFO" | jq -r '.result.id')
INSTANCE_URL=$(echo "$ORG_INFO" | jq -r '.result.instanceUrl')
ACCESS_TOKEN=$(echo "$ORG_INFO" | jq -r '.result.accessToken')

# Newer CLI versions redact accessToken — use show-access-token fallback
if [[ -z "$ACCESS_TOKEN" || "$ACCESS_TOKEN" == "null" || "$ACCESS_TOKEN" == *"REDACTED"* ]]; then
  ACCESS_TOKEN=$(echo "y" | sf org auth show-access-token --target-org "$ORG_ALIAS" --no-prompt --json 2>/dev/null | jq -r '.result.accessToken // empty')
fi

if [[ -z "$ORG_ID" || -z "$INSTANCE_URL" || -z "$ACCESS_TOKEN" || "$ACCESS_TOKEN" == "null" ]]; then
  echo "Error: Could not retrieve org details. Is the org authenticated?"
  exit 1
fi

echo "Org ID: $ORG_ID"
echo "Instance URL: $INSTANCE_URL"
echo ""

# Pre-flight checks
echo "🔍 Running pre-flight checks..."
echo ""

PREFLIGHT_FAILED=false

# Check Einstein GPT is enabled (critical) — via SOAP readMetadata
GENAI_CHECK=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>EinsteinGptSettings</met:type><met:fullNames>EinsteinGpt</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null | grep -o "<enableEinsteinGptPlatform>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$GENAI_CHECK" == "true" ]]; then
  echo "  ✅ Einstein GPT enabled"
else
  echo "  ❌ Einstein GPT NOT enabled (required)"
  PREFLIGHT_FAILED=true
fi

# Check Agentforce Agent is enabled (required) — via SOAP readMetadata
COPILOT_CHECK=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>EinsteinCopilotSettings</met:type><met:fullNames>EinsteinCopilot</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null | grep -o "<enableEinsteinGptCopilot>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$COPILOT_CHECK" == "true" ]]; then
  echo "  ✅ Agentforce Agent enabled"
else
  echo "  ❌ Agentforce Agent NOT enabled (required)"
  PREFLIGHT_FAILED=true
fi

# Check Agentforce Studio / Agent Platform is enabled (required) — via SOAP readMetadata.
# AgentPlatformSettings.enableAgentPlatform (OrgPreference AgentPlatformEnabled) gates
# SalesDealAgentSettings: core's DealAgentEnabledOrgPreference validates the Agentforce
# Platform preference and rejects Deal Agent enablement if it is off, so this must pass
# before we attempt the SalesDealAgent update below.
AGENT_PLATFORM_CHECK=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>AgentPlatformSettings</met:type><met:fullNames>AgentPlatform</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null | grep -o "<enableAgentPlatform>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$AGENT_PLATFORM_CHECK" == "true" ]]; then
  echo "  ✅ Agentforce Studio (Agent Platform) enabled"
else
  echo "  ❌ Agentforce Studio (Agent Platform) NOT enabled (required — gates Deal Agent)"
  PREFLIGHT_FAILED=true
fi

# Check Enhanced Notes (required dependency) — via SOAP readMetadata
NOTES_CHECK=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>EnhancedNotesSettings</met:type><met:fullNames>EnhancedNotes</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null | grep -o "<enableEnhancedNotes>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$NOTES_CHECK" == "true" ]]; then
  echo "  ✅ Enhanced Notes enabled"
else
  echo "  ❌ Enhanced Notes NOT enabled (required)"
  PREFLIGHT_FAILED=true
fi

# Check org edition compatibility
ORG_EDITION=$(sf data query --query "SELECT OrganizationType FROM Organization" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -r '.result.records[0].OrganizationType')
echo "  â„šī¸  Org Edition: $ORG_EDITION"

if [[ "$ORG_EDITION" == "Developer Edition" ]]; then
  echo "  âš ī¸  Warning: Pipeline Management may have limited functionality in Developer Edition"
fi

echo ""

if [[ "$PREFLIGHT_FAILED" == "true" ]]; then
  echo "❌ Pre-flight checks failed. Run ./enable-prerequisites.sh first."
  exit 1
fi

echo "✅ Pre-flight checks passed"
echo ""

# Check if already enabled (via SOAP readMetadata — SalesDealAgentSettings is NOT queryable via SOQL)
echo -n "Checking current SalesDealAgent status... "
CURRENT_STATUS=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>SalesDealAgentSettings</met:type><met:fullNames>SalesDealAgent</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null | grep -o "<enableDealAgent>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$CURRENT_STATUS" == "true" ]]; then
  echo "✅ (already enabled)"
  echo ""
  echo "✅ Pipeline Management is already enabled"
  exit 0
fi

echo "âŗ (not enabled)"
echo ""

# Enable via SOAP API v64.0
echo "Enabling Pipeline Management via SOAP API v64.0..."
echo ""

SOAP_REQUEST=$(cat <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
  <soapenv:Header>
    <met:SessionHeader>
      <met:sessionId>{{ACCESS_TOKEN}}</met:sessionId>
    </met:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
    <met:updateMetadata>
      <met:metadata xsi:type="met:SalesDealAgentSettings" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <met:fullName>SalesDealAgent</met:fullName>
        <met:enableDealAgent>true</met:enableDealAgent>
        <met:enableDealAgentAutoApproveAllTasks>false</met:enableDealAgentAutoApproveAllTasks>
      </met:metadata>
    </met:updateMetadata>
  </soapenv:Body>
</soapenv:Envelope>
EOF
)

# Substitute access token
SOAP_REQUEST="${SOAP_REQUEST//\{\{ACCESS_TOKEN\}\}/$ACCESS_TOKEN}"

# Send SOAP request
RESPONSE=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=utf-8" \
  -H "SOAPAction: update" \
  -d "$SOAP_REQUEST")

# Check response
if echo "$RESPONSE" | grep -q "<success>true</success>"; then
  echo "✅ SOAP API call succeeded"
else
  echo "❌ SOAP API call failed"
  echo ""
  echo "Response:"
  echo "$RESPONSE"
  exit 1
fi

echo ""

# Verify enablement (via SOAP readMetadata)
echo "🔍 Verifying Pipeline Management is enabled..."
sleep 2  # Brief wait for propagation

VERIFY_RESULT=$(curl -s "${INSTANCE_URL}/services/Soap/m/64.0" \
  -H "Content-Type: text/xml; charset=UTF-8" \
  -H "SOAPAction: readMetadata" \
  -d "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
  <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
  <soapenv:Body><met:readMetadata><met:type>SalesDealAgentSettings</met:type><met:fullNames>SalesDealAgent</met:fullNames></met:readMetadata></soapenv:Body>
</soapenv:Envelope>" 2>/dev/null)

VERIFY_DEAL_AGENT=$(echo "$VERIFY_RESULT" | grep -o "<enableDealAgent>[^<]*" | grep -o "true\|false" || echo "")

if [[ "$VERIFY_DEAL_AGENT" == "true" ]]; then
  echo "  ✅ enableDealAgent: true"

  AUTO_APPROVE=$(echo "$VERIFY_RESULT" | grep -o "<enableDealAgentAutoApproveAllTasks>[^<]*" | grep -o "true\|false" || echo "false")
  echo "  â„šī¸  enableDealAgentAutoApproveAllTasks: $AUTO_APPROVE (default: false)"

  echo ""
  echo "✅ Pipeline Management enabled successfully"
  echo ""
  echo "Next steps:"
  echo "  1. Run ./create-flow.sh $ORG_ALIAS to create the suggestion processing flow"
  echo "  2. Run ./create-agent.sh $ORG_ALIAS <bundle-path> to create and activate the agent"
else
  echo "  ❌ Verification failed"
  echo ""
  echo "Query result:"
  echo "$VERIFY_RESULT"
  exit 1
fi
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall