StringIndexOutOfBoundsException: String index out of range: -1

JustinDupree -

The StringIndexOutOfBoundsException: String index out of range: -1 error indicates that an ask is missing an associated say. Example with JSON (as this happens most commonly in WebAPI):

     {
       "tropo":[
          {
             "ask":{
                "name":"initial_text",
                "choices":{
                   "value":"[ANY]"
                }
             }
          }
       ]
    }

That would need to be:

{
   "tropo":[
      {
         "ask":{
            "say":[
               {
                  "value":"What's your name?"
               }
            ],
            "choices":{
               "value":"[ANY]"
            },
            "name":"initial_text"
         }
      }
   ]
}

This can also happen if the developer assigns an event to each say, so there's no default say, like so:

    {
       "tropo":[
          {
             "ask":{
                "attempts":3,
                "say":[
                   {
                      "value":"Sorry, I did not hear anything.",
                      "event":"timeout"
                   },
                   {
                      "value":"Don't think that was a year. ",
                      "event":"nomatch:1"
                   }
                ],
                "choices":{
                   "value":"[4 DIGITS]"
                },
                "bargein":true,
                "timeout":60,
                "name":"year",
                "required":true
             }
          }
       ]
    }

That would need to be

    {
       "tropo":[
          {
             "ask":{
                "attempts":3,
                "say":[
                   {
                      "value":"Sorry, I did not hear anything.",
                      "event":"timeout"
                   },
                   {
                      "value":"Don't think that was a year. ",
                      "event":"nomatch:1"
                   },
                   {
                      "value":"What is your birth year?"
                   }
                ],
                "choices":{
                   "value":"[4 DIGITS]"
                },
                "bargein":true,
                "timeout":60,
                "name":"year",
                "required":true
             }
          }
       ]
    }
Have more questions? Submit a request

0 Comments

Article is closed for comments.