asterisk-sapcontactcenter-integration
asterisk-sapcontactcenter-integration
1
A. Asterisk Configuration ( extensions.conf ):
1. Define a Context for Incoming SAP Calls: Create a new context or
modify an existing one in your extensions.conf file. This context will
handle incoming calls from the SAP Contact Center.
[from-sap]
exten => _X.,1,Answer()
exten => _X.,n,Wait(1) ; Wait for a second
exten => _X.,n,NoOp(Incoming call from SAP Contact Center)
exten => _X.,n,Set(CALLERID(num)=${CALLERID(num)})
exten => _X.,n,Set(CALLERID(name)=${CALLERID(name)})
exten => _X.,n,Set(SAP_ORIGINAL_DID=${EXTEN}) ; Store the original dialed number
exten => _X.,n,Goto(ivr-processing,s,1) ; Jump to the IVR context
exten => _X.,n,Hangup()
• [from-sap]: The name of the context. Choose a descriptive name.
• exten => _X.,1,Answer(): Answers the call.
• exten => _X.,n,Wait(1): Waits for 1 second. Sometimes needed
for signaling stability.
• exten => _X.,n,NoOp(Incoming call from SAP Contact
Center): Logs a message for debugging.
• exten => _X.,n,Set(CALLERID(num)=${CALLERID(num)}) and
exten => _X.,n,Set(CALLERID(name)=${CALLERID(name)}): Pre-
serves the original Caller ID. Crucial for transferring the call back
correctly.
• exten => _X.,n,Set(SAP_ORIGINAL_DID=${EXTEN}): Saves the di-
aled number (the extension dialed in Asterisk) to a variable. You
might need this later when transferring back to the SAP Contact
Center. This assumes the SAP Contact Center is passing the origi-
nal dialed number (DID) to Asterisk.
• exten => _X.,n,Goto(ivr-processing,s,1): Jumps to another
context (e.g., ivr-processing) where you’ll define the actual IVR
logic. Replace ivr-processing with the actual name of your IVR
context. The s is the start point, and 1 is the priority.
• exten => _X.,n,Hangup(): Hangs up the call if it reaches the end
of the context.
2. Define an IVR Context: Create a new context for your multi-turn
conversation. This is where your Asterisk IVR logic will reside. This is a
simplified example:
[ivr-processing]
exten => s,1,Answer()
exten => s,n,Background(welcome-message) ; Play a welcome message
exten => s,n,Read(USER_INPUT,enter-option,1,3,30) ; Read user input (1 digit, 3 attempt
exten => 1,1,Goto(option-1,s,1)
exten => 2,1,Goto(option-2,s,1)
2
exten => 3,1,Goto(transfer-to-sap,s,1) ; Example of transferring back
exten => t,1,Hangup()
exten => i,1,Hangup()
[option-1]
exten => s,1,Playback(option-1-message)
exten => s,n,Hangup()
[option-2]
exten => s,1,Playback(option-2-message)
exten => s,n,Hangup()
[transfer-to-sap]
exten => s,1,NoOp(Transferring call back to SAP Contact Center)
exten => s,n,Dial(SIP/sap_trunk/${SAP_RETURN_NUMBER}) ; Replace with your SAP transfer
exten => s,n,Hangup()
• Background(): Plays an audio file. Ensure the files are in the correct
format and location.
• Read(): Reads user input from the phone keypad. USER_INPUT is
the variable to store the input, enter-option is the prompt to play,
1 is the number of digits to read, 3 is the maximum attempts, and
30 is the timeout in seconds.
• Goto(): Jumps to another part of the dialplan based on the user’s
input.
• t: Timeout handler.
• i: Invalid input handler.
• transfer-to-sap: Context to transfer back to SAP.
3. Define the Transfer-Back Context (transfer-to-sap): This is criti-
cal. It defines how the call is transferred back to the SAP Contact Center.
[transfer-to-sap]
exten => s,1,NoOp(Transferring call back to SAP Contact Center)
exten => s,n,Dial(SIP/sap_trunk/${SAP_RETURN_NUMBER}) ; Replace with your SAP transfer
exten => s,n,Hangup()
• sap_trunk: Replace this with the name of your SIP trunk to the
SAP Contact Center defined in sip.conf.
• ${SAP_RETURN_NUMBER}: This is the number you want to transfer the
call to in the SAP Contact Center. This could be a specific queue
number, a specific agent’s extension, or a designated number for in-
bound calls. The variable should be set before calling this context.
• Alternatively, if you want to transfer based on the original dialed num-
ber, you can use: ini exten => s,n,Dial(SIP/sap_trunk/${SAP_ORIGINAL_DID})
This transfers the call back to the number initially dialed in Asterisk.
This is useful if the SAP Contact Center is configured to route calls
based on the DID.
3
4. Configure SIP Trunk ( sip.conf ):
Configure the SIP trunk to the SAP Contact Center. This configuration
is highly dependent on your network and security setup. Here’s a minimal
example:
[sap_trunk] ; Name of the trunk
type=friend ; This allows both sending and receiving calls
host=xxx.xxx.xxx.xxx ; IP address of the SAP Contact Center server
context=from-sap ; Context for incoming calls from SAP
dtmfmode=rfc2833 ; DTMF method (usually rfc2833)
disallow=all
allow=ulaw
allow=alaw
insecure=port,invite ; Remove this line in production environment
Replace xxx.xxx.xxx.xxx with the SAP Contact Center’s IP address. Re-
place from-sap with the context you created in step 1. IMPORTANT:
The insecure=port,invite line is insecure and should be removed in a
production environment. You’ll need to configure proper authentication
(username/password) in that case. Also, ensure the disallow and allow
settings match the codecs supported by the SAP Contact Center.
B. SAP Contact Center IVR Configuration:
1. Identify the Number to Transfer to Asterisk: Decide on a num-
ber on the Asterisk server that the SAP Contact Center will transfer
calls to. This should correspond to the extension you defined in your
extensions.conf file (e.g., the context from-sap).
2. Configure a SIP Route/Trunk in SAP Contact Center: In the
SAP Contact Center configuration, you need to define a SIP route/trunk
that points to the Asterisk server. The settings will be similar to those
you configured in Asterisk:
• Gateway/Proxy Address: The IP address of your Asterisk server.
• Transport Protocol: UDP, TCP, or TLS (must match Asterisk).
• Authentication (if required): Username and password for the
SIP trunk.
• Codec settings: Ensure the codecs are compatible with Asterisk
(typically G.711 a-law or u-law).
3. Modify the SAP Contact Center IVR Script:
• In the SAP Contact Center IVR design environment, add a “Transfer”
or “Route to External Number” activity.
• Configure this activity to transfer the call to the Asterisk number
you identified in step 1. You will likely need to specify the SIP
route/trunk you created in step 2.
Example IVR Flow (Conceptual):
4
• Start: The IVR script begins.
• Play Welcome Message: A welcome message is played to the
caller.
• Get Customer Input (Optional): Ask the caller to enter some
information.
• Transfer to Asterisk: The “Transfer” activity transfers the call
to the Asterisk extension (e.g., 1000). The SIP trunk to Asterisk is
selected in the transfer activity.
C. Example Configuration Summary:
• SAP Contact Center:
– SIP Trunk: Asterisk_Trunk, points to Asterisk IP 192.168.1.100.
Uses UDP, no authentication in this basic example (not recommended
for production).
– IVR Script: Transfers call to 1000 via Asterisk_Trunk.
• Asterisk sip.conf:
[sap_trunk]
type=friend
host=192.168.1.200 ; SAP Contact Center IP
context=from-sap
dtmfmode=rfc2833
disallow=all
allow=ulaw
allow=alaw
insecure=port,invite
• Asterisk extensions.conf:
[from-sap]
exten => _X.,1,Answer()
exten => _X.,n,Wait(1)
exten => _X.,n,NoOp(Incoming call from SAP Contact Center)
exten => _X.,n,Set(CALLERID(num)=${CALLERID(num)})
exten => _X.,n,Set(CALLERID(name)=${CALLERID(name)})
exten => _X.,n,Set(SAP_ORIGINAL_DID=${EXTEN})
exten => _X.,n,Goto(ivr-processing,s,1)
exten => _X.,n,Hangup()
[ivr-processing]
exten => s,1,Answer()
exten => s,n,Background(welcome-message)
exten => s,n,Read(USER_INPUT,enter-option,1,3,30)
exten => 1,1,Goto(option-1,s,1)
exten => 2,1,Goto(option-2,s,1)
exten => 3,1,Goto(transfer-to-sap,s,1)
5
exten => t,1,Hangup()
exten => i,1,Hangup()
[option-1]
exten => s,1,Playback(option-1-message)
exten => s,n,Hangup()
[option-2]
exten => s,1,Playback(option-2-message)
exten => s,n,Hangup()
[transfer-to-sap]
exten => s,1,NoOp(Transferring call back to SAP Contact Center)
exten => s,n,Set(SAP_RETURN_NUMBER=1234) ; Set the number in SAP you want to transfer t
exten => s,n,Dial(SIP/sap_trunk/${SAP_RETURN_NUMBER}) ; Transfer back to a specific nu
exten => s,n,Hangup()
– IP Addresses: 192.168.1.200 (SAP), 192.168.1.100 (Asterisk)
– The SAP IVR transfers to 1000 on Asterisk.
– Asterisk from-sap context handles the incoming call.
– Asterisk IVR logic resides in the ivr-processing context.
– Asterisk transfers the call back to SAP’s extension 1234 using the
transfer-to-sap context.
IV. Important Considerations:
• Codecs: Ensure that the audio codecs used by the SAP Contact Center
and Asterisk are compatible. Common codecs include G.711 a-law and
u-law, and G.729.
• DTMF: Configure DTMF (Dual-Tone Multi-Frequency) settings prop-
erly. rfc2833 is a common and reliable DTMF method. In sip.conf,
use dtmfmode=rfc2833.
• SIP Options Pings: Configure SIP options pings on both sides to keep
the SIP trunk alive. This helps detect and recover from network issues.
• NAT Traversal: If the SAP Contact Center or Asterisk server is behind
a NAT firewall, you need to configure NAT settings correctly. This might
involve using STUN or TURN servers.
• Security: Implement proper security measures, especially in a production
environment. This includes:
– Strong passwords for SIP authentication.
– TLS encryption for SIP signaling.
– SRTP encryption for audio.
– Firewall rules to restrict access to the SIP ports.
• Debugging: Use the Asterisk CLI (Command Line Interface) and SAP
Contact Center logs to troubleshoot issues. Use the sip debug command
in Asterisk to see SIP signaling.
• Testing: Thoroughly test the call flow in both directions (SAP -> As-
6
terisk and Asterisk -> SAP). Test different scenarios, including timeouts,
invalid input, and error conditions.
• SAP_RETURN_NUMBER: Pay close attention to the SAP_RETURN_NUMBER.
It can be a queue number, a DID, or a specific agent’s extension within
the SAP Contact Center. The specific configuration will depend on how
your SAP Contact Center is configured to route incoming calls. Consider
using the SAP_ORIGINAL_DID if you want to route back based on the
initially dialed number.
• Early Media: Configure early media if you want the caller to hear
progress tones (e.g., ringing) or announcements before the call is fully
established.
V. Key Configuration Points for the SIP Trunk:
This table summarizes the critical configuration elements for the SIP trunk.
These settings must be consistent on both the SAP Contact Center and Asterisk:
7
SAP Contact Asterisk ( sip.conf
Parameter
Center ) Notes
Username and
Authentication Username and Authentication is crucial for
password (if password (if security. Use strong
required). required). Use passwords.
secret in sip.conf
for the password.
List of supported
Codecs Use disallow=all The order of codecs matters.
codecs (e.g., ulaw, and then The first codec listed is the
alaw, g729). allow=ulaw, preferred codec. G.711
allow=alaw, etc. (ulaw/alaw) are the most
Specify the codecs common and widely
in order of supported.
preference.
DTMF rfc2833, inband, dtmfmode=rfc2833 rfc2833 sends DTMF tones
Mode or info. is the most reliable.
as separate RTP packets.
inband sends the tones as
part of the audio stream.
info uses SIP INFO
messages. rfc2833 is
generally preferred.
Varies by system.
Insecure insecure=port,inviteThis setting bypasses certain
This is NOT security checks. Use only for
recommended for testing or development.
production Remove this line in
environments. Use production and configure
proper username/password
authentication authentication.
instead.
8
• Codec Mismatch: A common problem is codec mismatch. Double-check
that the codecs are configured correctly on both sides.
• NAT Issues: If either server is behind NAT, NAT traversal can be tricky.
Configure STUN or TURN servers if necessary.
• DNS Resolution: If you are using hostnames instead of IP addresses,
ensure that DNS is configured correctly.
Connecting SAP Contact Center and Asterisk is a complex task that requires a
good understanding of both systems and SIP protocols. This guide provides a
detailed overview of the configuration steps involved. Remember to adapt the
example configurations to your specific environment and security requirements.
Thorough testing is essential to ensure a successful integration. Good luck!