How to create an IVR stress test using TestIVR

In this post we are going to develop an IVR stress test using TestIVR

In the previous article I discussed how you can implement an IVR experience test using TestIVR API. I also discussed how you can implement an IVR feature test using TestIVR API. The load test is also discussed in another article. In this post I am going to discuss IVR Stress Testing and how you can implement an IVR Stress Test using TestIVR.

IVR stress testing, evaluates if systems can handle periods of high demand well above normal levels. During an IVR stress test, a large number of calls are generated and directed to the system under test for a period of time. The system's performance is then monitored to see how well it handles the increased traffic. This testing can help to identify any areas of the system that may need to be improved in order to handle a high volume of calls. So let's discuss how we can implement an IVR stress test using TestIVR.

After signing up the TestIVR web portal will provide you with an "API key" which can be used to call the TestIVR RESTful API. Using the API key you can call the TestIVR stress testing tool via different tools such as "curl", python libraries such as "requests".

The TestIVR API end point is https://api.testivr.com/. Keep in mind that in all your API calls to TestIVR API endpoint, you should add your "API key" in a Header called "Authorization" and you need to add "Api-Key " at its begining. So for instance in "curl" you will have something like (replace XXXXX with your "API key"):


curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Api-Key XXXXX" \
  -d '{
    "description":"sample path"
  }' https://api.testivr.com/path/
                

Or in python:

import requests

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Api-Key XXXXX',
}

json_data = {
    'description': 'sample path',
}

response = requests.post('https://api.testivr.com/path/', headers=headers, json=json_data)
                

Similar to experience test and load test, to develop an IVR stress test using TestIVR, you should start with creating a "path". As discussed in the previous articles, a "path" is basically a route for your test to follow. Later you can add "action"s (such as pressing a button or saying something to the IVR) to this path. Here I am going to use the same path and actions I created in another article. The id of that path was "3". So we can take a look at that path by submitting a GET request to path/ endpoint and passing 3/ as the url parameter:

curl --request GET \
  -k \
  --url https://api.testivr.com/path/3/ \
  --header 'Authorization: Api-Key XXXXX'
                

The API will response with something like this:

{
  "count":1,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":3,
      "created_at":"2022-10-24T23:15:41.262451Z",
      "description":"path to sales",
      "user":1
    }
  ]
}
              

To see the "action"s created on path "3" you can submit a GET request to action/ endpoint and pass the path id as a parameter like ?path=3:

curl --request  GET \
    -k \
    --url https://api.testivr.com/action/?path=3 \
    -H "Authorization: Api-Key XXXXX"
              

And the response will be:

{
  "count":4,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":3,
      "created_at":"2022-10-24T23:17:34.962940Z",
      "order":0,
      "type":"listen",
      "value":"Hello, how can we direct your call? Press 1 for sales, or say sales. To reach support, press 2 or say support.",
      "description":"listening to the ivr intro",
      "asr_threshold":0.9,
      "pause_before":0.0,
      "pause_after":0.0,
      "user":1,
      "path":3
    },
    {
      "id":4,
      "created_at":"2022-10-24T23:22:34.685174Z",
      "order":1,
      "type":"press",
      "value":"1",
      "description":"press 1",
      "asr_threshold":0.9,
      "pause_before":0.0,
      "pause_after":1.0,
      "user":1,
      "path":3
    },
    {
      "id":5,
      "created_at":"2022-10-24T23:24:28.167247Z",
      "order":2,
      "type":"listen",
      "value":"You asked for sales, please hold",
      "description":"listening to the prompt",
      "asr_threshold":0.9,
      "pause_before":0.0,
      "pause_after":1.0,
      "user":1,
      "path":3
    },{
      "id":7,
      "created_at":"2022-10-25T00:45:29.329226Z",
      "order":3,
      "type":"command",
      "value":"terminate",
      "description":"terminating the call",
      "asr_threshold":0.9,
      "pause_before":0.0,
      "pause_after":0.0,
      "user":1,
      "path":3
    }
  ]
}
              

In the above actions, the test basically first listens for an intro from the IVR system. Then it presses number 1 on the keypad. Then it listens for another prompt, and at the end it terminates the call. You can read more detail about how we created the above actions in the previous article.

The next step is to setup the stress test using the defined path. You can do that by submitting a POST request to /general/test/ endpoint and set test_type to stress. Important parameters to pass are:

      path: the path you want to use for your test.
      phone: the phone number of the IVR you want to run the test on
      calls: the total number of calls you want to run for the test
      levels: the total number of levels you want to run for the test
      test_type: the type of the test, in this case you should set it to stress

TestIVR will run several levels of calls through the the provided phone number. The number of levels you want to run should be passed via the levels parameter. In each level, TestIVR will make multiple simultaneous calls, the number of calls will be the same in each level and equals to calls/levels. The total number of calls in all levels will be equal to the value passed as calls parameter above. For instance if you pass "600" for calls and "3" for levels, TestIVR will make 3 levels of calls to the IVR system. In each level TestIVR will make 200 calls to the IVR system.

So in our case I am going with:

curl -X POST \
  -k \
  --url https://api.testivr.com/general/test/ \
  --header "Content-Type: application/json" \
  --header "Authorization: Api-Key XXXXX" \
  --data '{
      "name": "sales path stress test ",
      "description":"stress test for sales path",
      "path": 3,
      "phone": "16506839455",
      "levels": 3,
      "calls": 6,
      "test_type": "stress"
  }'
                

And the result will be like this:

{
  "status": "OK",
  "data": {
    "id": 2,
    "created_at": "2022-11-18T00:37:50.245812Z",
    "description": "stress test for sales path",
    "name": "sales path stress test",
    "phone": "16506839455",
    "levels": 3,
    "calls": 6,
    "test_type": "stress",
    "user": 1,
    "path": 3
  }
}
                

From above you need to keep in mind what is the id for your new stress test, which in this case is 2.

Now the stress test will run, it may take a while since we have multiple levels of calls to go through. Keep in mind that each run will have separate set of outcomes, a run can fail due to various reason such as IVR system declining the call, or the promopt doesn't match the expected values.

If you need to pull the outcomes you need to first pull the test id, to do that you can submit a GET request to /general/run/ endpoint:

curl -X GET \
 -k \
 --url https://api.testivr.com/general/run/ \
 --header "Content-Type: application/json" \
 --header "Authorization: Api-Key XXXXX"
                

The output goning to be like this:

{
  "count":12,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":12,
      "created_at":"2022-11-18T00:39:12.663368Z",
      "user":1,
      "load_test":2,
      "test":21
    },
  ...
    {
      "id":7,
      "created_at":"2022-11-18T00:37:50.472039Z",
      "user":1,
      "load_test":2,
      "test":16
    },
  ...
  ]
}
              

You see for the load_test with id "2" we have total of six results, each for one of the calls made to the system. To see the outcome of each test you need its test id. So for instance to see the outcome of the test with id "21" (first one above), you can submit the following request:

curl -X GET \
  -k \
  --url https://api.testivr.com/outcome/?test=21 \
  --header "Content-Type: application/json" \
  --header "Authorization: Api-Key XXXXX"
              

Note that we are filtering the outcomes based on the test id by adding ?test=21 to the request. The result will be like:

{
  "count":2,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":31,
      "created_at":"2022-11-18T00:39:27.377076Z",
      "outcome":"match",
      "value":"hello how can we direct your call press one for sales or say sales to reach support press two or say support",
      "expected_value":"Hello, how can we direct your call? Press 1 for sales, or say sales. To reach support, press 2 or say support.",
      "match_ratio":0.908256880733945,
      "user":1,
      "test":21,
      "action":3
    },
    {
      "id":33,
      "created_at":"2022-11-18T00:39:38.217121Z",
      "outcome":"match",
      "value":"you asked for sales please hold",
      "expected_value":"You asked for sales, please hold",
      "match_ratio":0.9523809523809523,
      "user":1,
      "test":21,
      "action":5
    }
  ]
}
              

In the response, each items of the resuls shows the outcome of one of the "actions" we had on the "path". We can see the "action" id in the action field of the response.

This article shows how you can create a simple stress test for IVR using TestIVR. Please let me know if you have any question through our email: support@testivr.com

We also provide a good document on our API which provides more detailed information on all the calls you can make to TestIVR.