Windows10
Windows10

Reputation: 51

How to collect the user input when make a call using Twilio API?

I am developing a simple application in C# which

I was able to make a call but not able to receive the user input Or status, I tried finishOnKey() but that didn't work, and it always provides status as completed. I didn't get much help from Twilio code sample, can someone redirect to correct article or provide the code to accomplish above.

Upvotes: 1

Views: 822

Answers (1)

philnash
philnash

Reputation: 73057

Twilio developer evangelist here.

Once a call is answered successfully, it doesn't matter how the call is finished, the final status it reaches will be "completed". You can see more about Twilio call statuses in this documentation. You can see that the final call statuses could be:

  • completed: call was answered successfully and then finished
  • no-answer: Twilio dialled the number but there was no answer before the timeout
  • busy: Twilio dialled the number but received a busy signal
  • cancelled: The number was dialled, but the call was then cancelled using the API before answering
  • failed: the carrier couldn't connect the call

If you are using <Gather> to take the user input, you should ensure you have set the action attribute to a URL in your application. That URL will receive a new webhook request when the user presses a digit. For example:

<Response>
  <Gather action="/gather_results" digits="1">
    <Say>... your content goes here ...</Say>
  </Gather>
</Response>

With the above TwiML a user would only have to press 1 key before the call is moved to the next stage and the webhook '/gather_results'.

The request to the /gather_results endpoint would include a body with a Digits parameter. If the user pressed "*" then the body of the request would include Digits=*, if the user pressed "1" then it would include Digits=1. You could then choose to do whatever you like with those results, including hanging up the call or recording the submitted digits.

Let me know if this helps at all.

Upvotes: 1

Related Questions