Learn some fundamental techniques for developing custom interactive voice response (IVR) functionalities and see example solutions to three common IVR enhancements when using SAP Business Communications Management.
Key Concept
Interactive voice response (IVR) is a technology that allows a computer and telephony systems to interact with humans through voice and dual-tone multi-frequency input. Today, IVR is the first level of communication between customers and most call centers. A well-designed IVR system not only provides a good customer experience, but also reduces interaction time, effectively reducing costs and increasing the service level of call centers.
SAP Business Communications Management (SAP BCM) is an advanced communication solution for multichannel contact centers and contact-intensive, multisite organizations. It replaces traditional hardware-based communication systems with a software-based IP telephony solution that can help make internal interactions (within the organizations) and external interactions (between internal staff and external customers and partners) more effective.
In SAP BCM, the IVR Administrator is the standard tool for designing Interactive Voice Response (IVR) applications to use within the SAP BCM system. The IVR Administrator provides various states (activities), such as PLAY, MENU, GET DIGITS, RECORD, and FORWARD, that cover the majority of functionalities needed in a call center.
However, there are functionalities you need that you cannot create with the IVR Administrator. Because SAP BCM was not originally built on the traditional SAP programming platforms — Java and ABAP — companies that use SAP BCM often find it difficult to develop additional functionalities. This article provides a framework for and some tips on how to implement IVR enhancements in SAP BCM using Python coding. The solutions outlined below require SAP BCM 6.0 or higher integrated with SAP CRM. They also require Python 2.4 or above.
Basic Custom Development Techniques
Before developing any custom IVR functionalities, two basic techniques are important to know. The first technique is editing the Python file to include custom code, which cannot be generated by the IVR Administrator. The second technique is interacting with the database (such as insert, update, and delete).These are the most useful techniques to know for developing a custom IVR application.
Technique 1: Editing Python File to Include Custom Code
You can modify Python code in SAP BCM in two ways: by directly editing the SAP BCM IVR application’s source files, or by creating custom methods using the Customizer file. This Customizer file is delivered with SAP BCM’s standard package.
Method 1: Create a basic SAP BCM IVR application with standard states using the IVR Administrator, and then edit the application’s Python source file (.py) directly. The application’s Python source file is generated when you activate an IVR application in SAP BCM IVR. There are two ways to compile this source file into a .pyc file:
- Restart the Contact Event Manager (CEM) process – which is the central SAP BCM process to manage all the events that come into central engine – using the Infrastructure Administration tool. You need to delete the old .pyc file before doing this.
- Update the version of the Python file in the SAP BCM’s System Administrator tool. If there is any existing .pyc file in the same directory, the update overrides it. In this case, you don’t need to delete the .pyc file.
Depending on which access rights to the system you have (either the Infrastructure Administrator or the System Administrator tool), you have the option to choose either one of these two ways.
Method 2: Create a custom method using the Customizer file. The Customizer file has a standard class IVR_Customize(ICustomize) with the snippet shown in Figure 1. Note that all the custom methods need to be declared in the section #=== Custom methods (utilities.).

Figure 1
Standard class IVR_Customize(ICustomize)
The two methods mentioned above have one main difference. The first method is used when you want a simple enhancement embedded directly inside the SAP BCM Python file. This method requires the modification to be inserted manually in as many places as needed. This method is more cumbersome and time consuming. Furthermore, you take the risk of accidentally erasing the manually modified code section if you choose to activate the IVR application from IVR Administrator tool again. The second method allows you to wrap the code inside a particular Python method definition section in the Customizer file. Then you call this Python method from the standard IVR state CUSTOM. This method provides more portability and efficiency. I use it in the example below.
Technique 2: Interacting with the Database
SAP BCM runs on the MS SQL database, which is the only database it supports at present. You can interact with the MS SQL database using Python coding provided that the necessary Python libraries for database operations have been imported, as shown in the snippet in Figure 2.

Figure 2
Import Python libraries for SQL database operation
Once this is done, trigger a SQL query through an Open Database Connectivity (ODBC) connection instance. Figure 3 is an example of how you would do this.

Figure 3
Trigger a SQL query through an ODBC connection instance
Note
The ODBC connection PY_SDN should be created manually in the system with a default database specified.
Three Topics in Custom IVR Development in SAP BCM
This section shows you how to use the above techniques to develop solutions for three common problems in SAP BCM IVR:
- Passing custom Call Attached Data (CAD) information to SAP CRM
- Logging customers’ IVR selections
- Automating the agent selection process through the IVR
Topic 1: Passing Custom CAD
Imagine your call center has an IVR that allows customers to make selections such as the country and region in which they live or the language they speak, or to key in their customer ID. This CAD information is collected on the SAP BCM side. To pass the CAD information from SAP BCM to SAP CRM, follow the four steps below.
Step 1. Use the Customizer file (Technique 1, above) to define a custom method SetDataParameters for SAP BCM. An example is shown in Figure 4.

Figure 4
Custom method SetDataParameters
In this example, customers are asked to select their country, city, and language in order to be routed to the correct agent group. These three values are input through dual-tone multi-frequency (DTMF) keys and are each assigned to one of three corresponding custom CAD parameters: Z_LANGUAGE, Z_COUNTRY, and Z_CITY in the SAP BCM back end.
Note
Make sure the method SetDataParameters has been declared in the section def ConfigureICustomizer(self): shown in Figure 1.
Step 2. Define a Customizing file in the System Administrator tool. Open the SAP BCM System Administrator tool, select the Applications view, and navigate to the correct Directories and Applications. In the Application tab, put the customizer file name in the Customizing file field. Click the Apply button to save the updated configuration (Figure 5).

Figure 5
Customizing file in the System Administration tool
Step 3. Call method SetDataParameters in CUSTOM state. You start by opening up your IVR Administrator tool and selecting (or defining it if it does not already exist) an IVR application of a specific customer. Inside that IVR application you can define a CUSTOM state by following menu path Edit > Insert new state > Custom. You then specify the State ID and other parameters and call method SetDataParameters (Figure 6).

Figure 6
Call custom method in CUSTOM state
Step 4. Add custom CAD parameters into the ExtraDataWhenAllocated string of the SAP BCM Call Center application. ExtraDataWhenAllocated has the following value string:
XML,FirstBName,FirstBNumber,Z_COUNTRY,Z_LANGUAGE,Z_CITY,CURRENTCUSTOMER.
The corresponding values need to be defined in a CAD profile on the SAP CRM side in order for all the parameters to be transmitted and received correctly. To achieve this, you have to:
- Define the CAD profile. Follow menu path Customer Relationship Management > Interaction Center WebClient > Basic Functions > Communication Channels > Define Profiles for Contact Attached Data. Define a Z profile ZSAPBCMCAD, then add CAD group CRM_IC/BUPA for this profile, as shown in Figure 7. Note that you must use CRM_IC/BUPA as a CAD group name and ignore any warning message about this name.

Figure 7
Define CAD profile and group
- Create the three attributes Z_COUNTRY, Z_LANGUAGE, and Z_CITY under the above CAD group as shown in Figure 8.

Figure 8
Define Attributes for a CAD profile
- Assign the CAD profile to a business role. Follow menu path Customizing for Customer Relationship Management > Business Roles > Define Business Role. Here you assign the CAD profile to the business role that you want to access the CAD value. After completing this, you can retrieve CAD information on the SAP CRM side for further processing with the assigned business role.
As shown, SAP BCM offers a flexible way to manipulate and transmit CAD parameters to SAP CRM. Based on this CAD data, you can display information about customers on an SAP CRM screen, which helps agents interact better with customers.
Topic 2: IVR Selection for Reporting and Analytics
In this scenario, a company needs to log all customers’ selections in the IVR menu for the purpose of reporting and analyzing customer behavior. This proves helpful in many cases. For example, the call center managers want to know what the most wanted service of the call center is and then redesign it to bring that service to the front of the IVR flow for higher efficiency and a better customer experience.
To do this, follow the steps below.
1. Create a custom database table (Figure 9) named IVR_MENU_CHOICE. This table can reside in one of the standard SAP BCM databases (e.g., the CEM database) but it would be better to create a new database (e.g., BCM_ADDON) for it to avoid any potential problems when doing an upgrade in the future.

Figure 9
Create a custom database table
2. Create a custom method LogDTMFOption in the Customizer file (follow the above procedure). For each of the options the customer selects in the IVR, this method records the activity into a database with a predefined value. The result looks like what you see in Figure 10.

Figure 9
Entries in IVR_MENU_CHOICE database table
3. Create CUSTOM states in the IVR menu right after the MENU state. Assume that the call center’s customer has already made his or her choice in the MENU state earlier. In this CUSTOM state you call method LogDTMFOption to write an assigned value LogValue to the database table (Figure 11).

Figure 11
Call a custom method to assign logging value
Note
The assigned value for each selection can be different from the DTMF value of the MENU state. For example, if the IVR has two levels, and the customer selects option 1 at the first level and selects option 4 at the second level, you can log 14 into the database after he or she has made a selection at the second level menu. If the MENU state has three options for customers, you should have three CUSTOM states after that.
From the logged data, call center supervisors can review which queues or services are used most often, by which customers, and within what time frame. This data can help them perform the following activities:
- Rearranging the IVR menu and the workforce. The most selected service can be moved to the front of the menu (option 1) so that customers can select it first and save time at the menu level. An appropriate number of representatives can be assigned to the corresponding queues to handle the load.
- Designing a dynamic IVR. Supervisors can program the IVR selection order to change for each individual user based on their last selection. If the user selected one service more often in the past, you can offer this as the first option providing that you also record the customer’s ID or telephone number together with the IVR selection made.
If you pay attention to the order of all IVR options, you can help customers find the option or service they are looking for faster, hence reducing the time they stay on the queues.
Topic 3: Automated Agent Selection
In this situation, customers want to talk to a specific operator but they don’t know the operator extension. They do, however, know the operator’s name.
Use the three custom fields in table dbo.INObject of the CEM database to associate an operator with a lookup ID and prompt file, which spells out the operator name and operator extension. These custom fields are maintained with the user’s and operator’s account in the User Administrator interface as shown in Figure 12.

Figure 12
Custom fields in the User Administrator screen
The three fields Info 1, Info 2, Info 3 are mapped to fields Custom1, Custom2, and Custom3 in table dbo.INObject of the CEM database (Figure 13). Additional information is stored in these fields and used as lookup data for a specific operator.

Figure 13
Custom fields in the CEM database
In this solution, you allow the customers to use DTMF keys to input the first three characters of an operator’s first name using digits. Each character is represented by a digit (Table 1), which is similar to the traditional phone keypad (Figure 14).

Table 1
Correspondence between Roman letters and DTMF digits

Figure 14
Traditional telephone keypad
If a customer looks for operator Steven McKenna, for example, he or she needs to translate the first three characters of the first name (STE) into digits. Based on the above table, those digits are 783 (S = 7, T = 8, E = 3). This DTMF value is called the lookup ID. When that customer keys in these three DTMF values, the system checks the entries in table dbo.INObject and may find that there is more than one entry having the same lookup ID; for instance, Rud Bolton, Steven McKenna, and Steven Rowley would all have the same lookup IDs. Although they all have lookup ID 783, they have different values for the other two custom fields (Table 2).

Table 2
Lookup table for operator name, lookup ID and audio file names
In this table, the Custom 1 field is the lookup ID value. The Custom 2 field is an audio file that serves as the prompt, and says the name of the operator. The Custom 3 field is the prompt saying the extension of that operator. The system then plays the two prompt files for the above three entries to customers so that customers can identify the extension they want to connect to (in this case, 116, 137, or 178). After a selection is made, the call can be forwarded to the appropriate operator. This functionality works the same way as a traditional switchboard, but the whole process is automated and does not require human operators to carry out the switching.
Steven Trinh Xuan Dung
Steven Trinh Xuan Dung is a senior consultant at ecenta APA Ltd, Singapore, and has four years of experience in SAP CRM and other SAP products, with a focus on Services and CTI. With a technical and functional background, he has contributed to many successful SAP projects worldwide.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.