Custom Voice Call Twilio

Recently, I started using Twilio for our own needs - we must provide users with real-time information about possible dangerous events that could occur in their home by SMS or voice call.

I tried using VoiceCall exactly as it was listed here - https://www.twilio.com/user/account/developer-tools/api-explorer/call-create . The scenario is that I want a robotic voice to explain what happened, so I need to generate an XML file for voice on demand. I have provided my own RestApi URL for voice that this file can generate via TWIML.

By default, Twilio will use this url to retrieve audio and other instructions at the time the call is made. Since the voice URL cannot contain parameters (because for some reason they were disabled) (for example, YES - http://mywebsite.com/api/sayVoice , NO - http://mywebsite.com/api/ sayVoice? eventId = 1 ) , you ALWAYS get the same sound (there is no way to identify a different type and generate DIFFERENT xml output (for different audio for the end user).

In the Twilio documentation examples, they only have static URLs, with no additional parameters, therefore, is this really the only way to use Twilio Call Api?

Too hard to say that such a precedent was not planned for Twilio. Has anyone tried using Twilio for a similar scenario?

Any suggestions for similar technologies for the same purpose?

+4
source share
1 answer

Found the problem at the end, you need to pass the parameters as RequestParams.

For example, this will work - Url=http://mywebsite.com/api/twilio/sayVoice?eventId=379and pathParam will not work Url=http://mywebsite.com/api/twilio/sayVoice/379.

Therefore, stay safe and use RequestParams.

+4
source

Source: https://habr.com/ru/post/1619361/


All Articles