Twilio callback status of an outbound call is always 'completed'












1















I'm trying to create an IVR Phone tree through REST API in Salesforce (Twilio API). The problem is that I can't catch any other callback status except 'completed'.



If the call was cancelled or there was no response on this call, Twilio sends a call response with 'completed' status anyway.



Moreover, a customer gets a voicemail with a recorded 'welcome' message and first phone tree question after an unsuccessful call attempt.



There is a code sample of how calls are created :



TwilioRestClient client = new TwilioRestClient(TwilioSID, TwilioToken);
Map<String,String> params = new Map<String, String>();

String webURL = webServerURL;

params.put('To', phone);
params.put('From', phoneFrom);
params.put('Url', webURL);
params.put('Method', 'GET');
params.put('FallbackUrl', webURL);
params.put('FallbackMethod', 'GET');
params.put('StatusCallback', webURL);
if (!System.Test.isRunningTest()) {
try {
TwilioCall call = client.getAccount().getCalls().create(params);
} catch(Exception ex) {
}
}


In addition, I was trying to add 'StatusCallbackEvent' parameter (link to Twilio documentation - https://www.twilio.com/docs/voice/twiml#callstatus-values) :



params.put('StatusCallbackEvent', 'busy canceled completed failed no-answer');

// and other optiions like :
// params.put('StatusCallbackEvent', 'busy');
// params.put('StatusCallbackEvent', 'canceled');
// params.put('StatusCallbackEvent', 'completed');
// params.put('StatusCallbackEvent', 'failed');
// params.put('StatusCallbackEvent', 'no-answer');


But there was no any difference in a callback status after failed calls.



How should I make calls to get Twilio call responses with all finalized statuses ('busy', 'failed', 'no-answer', etc ...) ?










share|improve this question



























    1















    I'm trying to create an IVR Phone tree through REST API in Salesforce (Twilio API). The problem is that I can't catch any other callback status except 'completed'.



    If the call was cancelled or there was no response on this call, Twilio sends a call response with 'completed' status anyway.



    Moreover, a customer gets a voicemail with a recorded 'welcome' message and first phone tree question after an unsuccessful call attempt.



    There is a code sample of how calls are created :



    TwilioRestClient client = new TwilioRestClient(TwilioSID, TwilioToken);
    Map<String,String> params = new Map<String, String>();

    String webURL = webServerURL;

    params.put('To', phone);
    params.put('From', phoneFrom);
    params.put('Url', webURL);
    params.put('Method', 'GET');
    params.put('FallbackUrl', webURL);
    params.put('FallbackMethod', 'GET');
    params.put('StatusCallback', webURL);
    if (!System.Test.isRunningTest()) {
    try {
    TwilioCall call = client.getAccount().getCalls().create(params);
    } catch(Exception ex) {
    }
    }


    In addition, I was trying to add 'StatusCallbackEvent' parameter (link to Twilio documentation - https://www.twilio.com/docs/voice/twiml#callstatus-values) :



    params.put('StatusCallbackEvent', 'busy canceled completed failed no-answer');

    // and other optiions like :
    // params.put('StatusCallbackEvent', 'busy');
    // params.put('StatusCallbackEvent', 'canceled');
    // params.put('StatusCallbackEvent', 'completed');
    // params.put('StatusCallbackEvent', 'failed');
    // params.put('StatusCallbackEvent', 'no-answer');


    But there was no any difference in a callback status after failed calls.



    How should I make calls to get Twilio call responses with all finalized statuses ('busy', 'failed', 'no-answer', etc ...) ?










    share|improve this question

























      1












      1








      1








      I'm trying to create an IVR Phone tree through REST API in Salesforce (Twilio API). The problem is that I can't catch any other callback status except 'completed'.



      If the call was cancelled or there was no response on this call, Twilio sends a call response with 'completed' status anyway.



      Moreover, a customer gets a voicemail with a recorded 'welcome' message and first phone tree question after an unsuccessful call attempt.



      There is a code sample of how calls are created :



      TwilioRestClient client = new TwilioRestClient(TwilioSID, TwilioToken);
      Map<String,String> params = new Map<String, String>();

      String webURL = webServerURL;

      params.put('To', phone);
      params.put('From', phoneFrom);
      params.put('Url', webURL);
      params.put('Method', 'GET');
      params.put('FallbackUrl', webURL);
      params.put('FallbackMethod', 'GET');
      params.put('StatusCallback', webURL);
      if (!System.Test.isRunningTest()) {
      try {
      TwilioCall call = client.getAccount().getCalls().create(params);
      } catch(Exception ex) {
      }
      }


      In addition, I was trying to add 'StatusCallbackEvent' parameter (link to Twilio documentation - https://www.twilio.com/docs/voice/twiml#callstatus-values) :



      params.put('StatusCallbackEvent', 'busy canceled completed failed no-answer');

      // and other optiions like :
      // params.put('StatusCallbackEvent', 'busy');
      // params.put('StatusCallbackEvent', 'canceled');
      // params.put('StatusCallbackEvent', 'completed');
      // params.put('StatusCallbackEvent', 'failed');
      // params.put('StatusCallbackEvent', 'no-answer');


      But there was no any difference in a callback status after failed calls.



      How should I make calls to get Twilio call responses with all finalized statuses ('busy', 'failed', 'no-answer', etc ...) ?










      share|improve this question














      I'm trying to create an IVR Phone tree through REST API in Salesforce (Twilio API). The problem is that I can't catch any other callback status except 'completed'.



      If the call was cancelled or there was no response on this call, Twilio sends a call response with 'completed' status anyway.



      Moreover, a customer gets a voicemail with a recorded 'welcome' message and first phone tree question after an unsuccessful call attempt.



      There is a code sample of how calls are created :



      TwilioRestClient client = new TwilioRestClient(TwilioSID, TwilioToken);
      Map<String,String> params = new Map<String, String>();

      String webURL = webServerURL;

      params.put('To', phone);
      params.put('From', phoneFrom);
      params.put('Url', webURL);
      params.put('Method', 'GET');
      params.put('FallbackUrl', webURL);
      params.put('FallbackMethod', 'GET');
      params.put('StatusCallback', webURL);
      if (!System.Test.isRunningTest()) {
      try {
      TwilioCall call = client.getAccount().getCalls().create(params);
      } catch(Exception ex) {
      }
      }


      In addition, I was trying to add 'StatusCallbackEvent' parameter (link to Twilio documentation - https://www.twilio.com/docs/voice/twiml#callstatus-values) :



      params.put('StatusCallbackEvent', 'busy canceled completed failed no-answer');

      // and other optiions like :
      // params.put('StatusCallbackEvent', 'busy');
      // params.put('StatusCallbackEvent', 'canceled');
      // params.put('StatusCallbackEvent', 'completed');
      // params.put('StatusCallbackEvent', 'failed');
      // params.put('StatusCallbackEvent', 'no-answer');


      But there was no any difference in a callback status after failed calls.



      How should I make calls to get Twilio call responses with all finalized statuses ('busy', 'failed', 'no-answer', etc ...) ?







      callback salesforce twilio






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 9:12









      George AtkinsonGeorge Atkinson

      61




      61
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Twilio developer evangelist here.



          When you set a URL for the StatusCallback then by default you will only receive callbacks when the call is "completed". A completed call may have different reasons for being completed though, such as "busy", "failed", "no-answer" or plain "completed" and you can read that value from the CallStatus parameter that is sent to the URL.



          You can subscribe to other events though, as you tried. The only thing is you were trying to subscribe to the potential statuses and not the events themselves.



          For a call you can subscribe to "initiated", "ringing", "answered" and "completed". So try:



          params.put('StatusCallbackEvent', 'initiated ringing answered completed');





          share|improve this answer
























          • thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

            – George Atkinson
            Nov 21 '18 at 13:10













          • I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

            – philnash
            Nov 21 '18 at 13:18











          • No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

            – George Atkinson
            Nov 21 '18 at 13:28













          • Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

            – philnash
            Nov 21 '18 at 13:30











          • If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

            – George Atkinson
            Nov 21 '18 at 13:37











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408622%2ftwilio-callback-status-of-an-outbound-call-is-always-completed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Twilio developer evangelist here.



          When you set a URL for the StatusCallback then by default you will only receive callbacks when the call is "completed". A completed call may have different reasons for being completed though, such as "busy", "failed", "no-answer" or plain "completed" and you can read that value from the CallStatus parameter that is sent to the URL.



          You can subscribe to other events though, as you tried. The only thing is you were trying to subscribe to the potential statuses and not the events themselves.



          For a call you can subscribe to "initiated", "ringing", "answered" and "completed". So try:



          params.put('StatusCallbackEvent', 'initiated ringing answered completed');





          share|improve this answer
























          • thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

            – George Atkinson
            Nov 21 '18 at 13:10













          • I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

            – philnash
            Nov 21 '18 at 13:18











          • No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

            – George Atkinson
            Nov 21 '18 at 13:28













          • Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

            – philnash
            Nov 21 '18 at 13:30











          • If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

            – George Atkinson
            Nov 21 '18 at 13:37
















          0














          Twilio developer evangelist here.



          When you set a URL for the StatusCallback then by default you will only receive callbacks when the call is "completed". A completed call may have different reasons for being completed though, such as "busy", "failed", "no-answer" or plain "completed" and you can read that value from the CallStatus parameter that is sent to the URL.



          You can subscribe to other events though, as you tried. The only thing is you were trying to subscribe to the potential statuses and not the events themselves.



          For a call you can subscribe to "initiated", "ringing", "answered" and "completed". So try:



          params.put('StatusCallbackEvent', 'initiated ringing answered completed');





          share|improve this answer
























          • thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

            – George Atkinson
            Nov 21 '18 at 13:10













          • I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

            – philnash
            Nov 21 '18 at 13:18











          • No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

            – George Atkinson
            Nov 21 '18 at 13:28













          • Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

            – philnash
            Nov 21 '18 at 13:30











          • If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

            – George Atkinson
            Nov 21 '18 at 13:37














          0












          0








          0







          Twilio developer evangelist here.



          When you set a URL for the StatusCallback then by default you will only receive callbacks when the call is "completed". A completed call may have different reasons for being completed though, such as "busy", "failed", "no-answer" or plain "completed" and you can read that value from the CallStatus parameter that is sent to the URL.



          You can subscribe to other events though, as you tried. The only thing is you were trying to subscribe to the potential statuses and not the events themselves.



          For a call you can subscribe to "initiated", "ringing", "answered" and "completed". So try:



          params.put('StatusCallbackEvent', 'initiated ringing answered completed');





          share|improve this answer













          Twilio developer evangelist here.



          When you set a URL for the StatusCallback then by default you will only receive callbacks when the call is "completed". A completed call may have different reasons for being completed though, such as "busy", "failed", "no-answer" or plain "completed" and you can read that value from the CallStatus parameter that is sent to the URL.



          You can subscribe to other events though, as you tried. The only thing is you were trying to subscribe to the potential statuses and not the events themselves.



          For a call you can subscribe to "initiated", "ringing", "answered" and "completed". So try:



          params.put('StatusCallbackEvent', 'initiated ringing answered completed');






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 12:47









          philnashphilnash

          38.5k93554




          38.5k93554













          • thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

            – George Atkinson
            Nov 21 '18 at 13:10













          • I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

            – philnash
            Nov 21 '18 at 13:18











          • No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

            – George Atkinson
            Nov 21 '18 at 13:28













          • Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

            – philnash
            Nov 21 '18 at 13:30











          • If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

            – George Atkinson
            Nov 21 '18 at 13:37



















          • thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

            – George Atkinson
            Nov 21 '18 at 13:10













          • I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

            – philnash
            Nov 21 '18 at 13:18











          • No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

            – George Atkinson
            Nov 21 '18 at 13:28













          • Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

            – philnash
            Nov 21 '18 at 13:30











          • If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

            – George Atkinson
            Nov 21 '18 at 13:37

















          thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

          – George Atkinson
          Nov 21 '18 at 13:10







          thanks for the clarification about 'StatusCallback' and 'StatusCallbackEvent'. But it doesn't explain why dropped/unanswered calls have 'completed' status instead of 'cancelled'/'no-answer' and my customer gets a voicemail of the call that he doesn't respond. It would be great if you have some information about this. Because I don't understand how I can influence on Twilio responses any other way. Is it possible to cofigure it in Twillo account ? I couldn't find such settings on its side.

          – George Atkinson
          Nov 21 '18 at 13:10















          I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

          – philnash
          Nov 21 '18 at 13:18





          I am guessing you are trying to connect a call using <Dial>? Have you checked the DialCallStatus parameter that is sent to the action URL?

          – philnash
          Nov 21 '18 at 13:18













          No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

          – George Atkinson
          Nov 21 '18 at 13:28







          No, I'm not using <Dial> at all. TWiML instructions contain only <Say>, <Play> and <Gather> verbs (as I mentioned earlier it's an IVR phone tree). Making a call is carried out only by standard methods provided by Twilio package. Example in the description above.

          – George Atkinson
          Nov 21 '18 at 13:28















          Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

          – philnash
          Nov 21 '18 at 13:30





          Oh, I see. When voicemail answers a call it is counted as an answered call. You could try answering machine detection to understand whether a human or a machine answers the phone and perhaps that would avoid this issue?

          – philnash
          Nov 21 '18 at 13:30













          If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

          – George Atkinson
          Nov 21 '18 at 13:37





          If I understand you correctly, I need to check who picked up the phone (machine or human), and it can be the reason of the issue. Is it right ? Because I tested it earlier by myself - started a call on my phone number and cancelled it manually. But the response was 'completed'

          – George Atkinson
          Nov 21 '18 at 13:37




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408622%2ftwilio-callback-status-of-an-outbound-call-is-always-completed%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()