diff --git a/.env.production.template b/.env.production.template index ad4be9e..3bc1b99 100644 --- a/.env.production.template +++ b/.env.production.template @@ -114,6 +114,10 @@ ASTERISK_AMI_HOST= ASTERISK_AMI_PORT=5038 ASTERISK_AMI_USERNAME=mvpcc ASTERISK_AMI_SECRET= +# Password for the telecom.kz IP-trunk (endpoint [telecom-kz], user 86205414). +# Injected into /etc/asterisk/pjsip.conf at container start by +# deployment/asterisk/entrypoint.sh (replaces ChangeMe-TelecomKzPassword). +ASTERISK_TELECOM_KZ_PASSWORD= ASTERISK_AMI_EVENT_PREFIX=MVPCC ASTERISK_QUEUE_MAP_JSON={"voice_lab":"","voice_lab_ai":"","voice_lab_ivr":""} ASTERISK_BRIDGE_POLL_INTERVAL_SECONDS=1 diff --git a/deployment/asterisk/entrypoint.sh b/deployment/asterisk/entrypoint.sh index ff8ba3d..07f7199 100644 --- a/deployment/asterisk/entrypoint.sh +++ b/deployment/asterisk/entrypoint.sh @@ -11,6 +11,7 @@ password_1001="${ASTERISK_ENDPOINT_1001_PASSWORD:-${ASTERISK_AMI_SECRET:-ChangeM password_2001="${ASTERISK_ENDPOINT_2001_PASSWORD:-${ASTERISK_AMI_SECRET:-ChangeMe-2001}}" password_2002="${ASTERISK_ENDPOINT_2002_PASSWORD:-${ASTERISK_AMI_SECRET:-ChangeMe-2002}}" ami_secret="${ASTERISK_AMI_SECRET:-ChangeMe-AmiSecret}" +telecom_kz_password="${ASTERISK_TELECOM_KZ_PASSWORD:-ChangeMe-TelecomKzPassword}" external_address="${ASTERISK_EXTERNAL_ADDRESS:-92.38.48.166}" mkdir -p /etc/asterisk "$monitor_dir" "$primary_sounds_dir" "$legacy_sounds_dir" "$keys_dir" @@ -23,6 +24,7 @@ export ASTERISK_PASSWORD_1001="$password_1001" export ASTERISK_PASSWORD_2001="$password_2001" export ASTERISK_PASSWORD_2002="$password_2002" export ASTERISK_MANAGER_SECRET="$ami_secret" +export ASTERISK_TELECOM_KZ_PASSWORD_VALUE="$telecom_kz_password" export ASTERISK_EXTERNAL_ADDRESS_VALUE="$external_address" python3 - <<'PY' @@ -34,6 +36,7 @@ replacements = { "ChangeMe-2001": os.environ["ASTERISK_PASSWORD_2001"], "ChangeMe-2002": os.environ["ASTERISK_PASSWORD_2002"], "ChangeMe-AmiSecret": os.environ["ASTERISK_MANAGER_SECRET"], + "ChangeMe-TelecomKzPassword": os.environ["ASTERISK_TELECOM_KZ_PASSWORD_VALUE"], "92.38.48.166": os.environ["ASTERISK_EXTERNAL_ADDRESS_VALUE"], } diff --git a/deployment/asterisk/extensions.conf b/deployment/asterisk/extensions.conf index e575a50..490d938 100644 --- a/deployment/asterisk/extensions.conf +++ b/deployment/asterisk/extensions.conf @@ -117,3 +117,20 @@ exten => h,1,StopMixMonitor() [mvpcc-operators] exten => _X.,1,Dial(PJSIP/${EXTEN},30) same => n,Hangup() + +;======================================================================= +; Inbound context for Telecom.kz IP-trunk (endpoint [telecom-kz]). +; Routes the production DID 87273901485 straight into the AI-first +; voice lab entrypoint (7100). AudioSocket failure falls back to +; live operators inside the 7100 flow. +;======================================================================= +[from-telecom] +exten => 86205414,1,NoOp(Incoming from telecom.kz DID 87273901485 -> AI) + same => n,Set(CALLERID(dnid)=87273901485) + same => n,Goto(from-softphones,7100,1) + +exten => 87273901485,1,NoOp(Incoming from telecom.kz DID 87273901485 -> AI) + same => n,Goto(from-softphones,7100,1) + +exten => _X.,1,NoOp(Incoming from telecom.kz, DID=${EXTEN}) + same => n,Goto(from-softphones,7100,1) diff --git a/deployment/asterisk/pjsip.conf b/deployment/asterisk/pjsip.conf index 6890720..d9c6267 100644 --- a/deployment/asterisk/pjsip.conf +++ b/deployment/asterisk/pjsip.conf @@ -82,3 +82,43 @@ type=aor max_contacts=1 remove_existing=yes support_path=yes + +;======================================================================= +; Telecom.kz IP-trunk (no registration, identified by source IP). +; DID: 87273901485 +; SIP account: 86205414@sip.telecom.kz +; Password is injected at container start from ASTERISK_TELECOM_KZ_PASSWORD +; (see deployment/asterisk/entrypoint.sh). +;======================================================================= +[telecom-kz-aor] +type=aor +contact=sip:sip.telecom.kz:5060 +qualify_frequency=60 + +[telecom-kz-auth] +type=auth +auth_type=userpass +username=86205414 +password=ChangeMe-TelecomKzPassword + +[telecom-kz] +type=endpoint +context=from-telecom +disallow=all +allow=alaw,ulaw +aors=telecom-kz-aor +outbound_auth=telecom-kz-auth +from_user=86205414 +from_domain=sip.telecom.kz +direct_media=no +rtp_symmetric=yes +force_rport=yes +rewrite_contact=yes +trust_id_inbound=yes +send_rpid=yes +language=ru + +[telecom-kz-identify] +type=identify +endpoint=telecom-kz +match=92.46.61.21 diff --git a/scripts/deploy_gitlab.sh b/scripts/deploy_gitlab.sh index 90ee152..57f3f85 100755 --- a/scripts/deploy_gitlab.sh +++ b/scripts/deploy_gitlab.sh @@ -8,6 +8,7 @@ DEPLOY_DIR="${DEPLOY_DIR:-/home/gitlab-runner/deploy/call-center}" APP_IMAGE_NAME="${APP_IMAGE_NAME:-call-center-app}" APP_IMAGE_TAG="${APP_IMAGE_TAG:-${CI_COMMIT_SHORT_SHA:-latest}}" COMPOSE_FILE="${COMPOSE_FILE:-$DEPLOY_DIR/deployment/docker-compose.server.yml}" +ASTERISK_COMPOSE_FILE="${ASTERISK_COMPOSE_FILE:-$DEPLOY_DIR/deployment/docker-compose.asterisk.server.yml}" HEALTHCHECK_URL="${HEALTHCHECK_URL:-http://127.0.0.1:8080/health}" HEALTHCHECK_TIMEOUT_SECONDS="${HEALTHCHECK_TIMEOUT_SECONDS:-120}" @@ -131,3 +132,20 @@ fi wait_for_health docker ps --filter "name=^call-center-app$" --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}' + +# --------------------------------------------------------------------------- +# Asterisk PBX container. +# +# The asterisk compose file is kept separate because it uses network_mode:host +# and a dedicated Dockerfile. Source-based deploy now also brings it up so the +# voice channel (SIP trunks, WebRTC softphones) stays in sync with the rest of +# the platform on every push to the default branch. +# --------------------------------------------------------------------------- +if [[ -f "$ASTERISK_COMPOSE_FILE" ]]; then + echo "Deploying Asterisk PBX via $ASTERISK_COMPOSE_FILE" + "${COMPOSE_CMD[@]}" -f "$ASTERISK_COMPOSE_FILE" config -q + "${COMPOSE_CMD[@]}" -f "$ASTERISK_COMPOSE_FILE" up -d --build --force-recreate + docker ps --filter "name=^call-center-asterisk$" --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}' +else + echo "Asterisk compose file not found at $ASTERISK_COMPOSE_FILE, skipping" >&2 +fi