title: How to play a complete prompt and do a CURL request at the backend?
body: <p>The callflow I want to build:</p>
  
  <ol>
  <li>Play Welcome Prompt (5 seconds)</li>
  <li>Do a CURL request to an API based on the callerId number</li>
  <li>Based on the response of step 2, play another prompt or hangup the call</li>
  </ol>
  
  <p><strong>Problem</strong></p>
  
  <p>The Curl request may take upto 3 seconds of delay, I want to play the prompt and want to do a CURL request simultaneously, I have tried MOH, but the problem with MOH is that it stops playing the prompt when the CURL response is recieved. Actual callflow is:</p>
  
  <pre><code>exten =&gt; 1002,1,Progress()
  exten =&gt; 1002,n,StartMusicOnHold(T1)
  exten =&gt; 1002,n,Set(CURL_RESULT=${CURL(http://192.168.0.38/test.php?aparty=${CALLERID(num)})})
  exten =&gt; 1002,n,NoOp(isSubscriber:${CURL_RESULT})
  exten =&gt; 1002,n,GotoIf($["${CURL_RESULT}"!="0"]?lbl_call_hangup:)
  exten =&gt; 1002,n,StopMusicOnHold(T1)
  exten =&gt; 1002,n,Playback(welcome)
  exten =&gt; 1002,n,Read(DTMF,,0,n,1,10)
  exten =&gt; 1002,n,Hangup
  </code></pre>
  
  <p>What I want is to playing complete prompt and while playing the prompt, do the curl request at the backend. There is another solution we have tried which is to write a wrapper for this API call which returns immediately and another API call to get the result. </p>
  
  <p>Here is what we built:</p>
  
  <ol>
  <li>Do CURL request to wrapper which returns immediately</li>
  <li>Play Welcome Prompt</li>
  <li>Do CURL request to get the response of the initial request done in step 1</li>
  <li>-do the rest of the things-</li>
  </ol>
  
  <p>But the problem in this callflow is that the wrapper has to keep the request/response pair in memory, have to do alot of house keeping in case the call drops during step 2 etc.</p>
  
  <p><strong>Question</strong></p>
  
  <p>So is there a way in the dialplan to achieve playing of prompt and doing a curl request in the meanwhile.</p>
  
  <p>PS: Using astersik 13.18.3</p>