I'd like to get the specific SID for the Flow attached to a given Inbound Phone Number. I'd also like to get all the Inbound Phone Numbers attached to a given Flow SID.
I'm using Twilio's Inbound Phone Numbers API and Studio Flows API to connect specific Flows to specific Inbound Phone Numbers.
If I retrieve an Inbound Phone Number, part of the return data is the voice_url
which seems to represent the Studio Flow attached to that number for voice calls. That value is a URL like https://webhooks.twilio.com/v1/Accounts/ACXXXXXXXXXXXX/Flows/FWXXXXXXXXXXXXX
. I assume that the FWXXXX
part is the SID of the Flow. Is there a better way to discover that SID?
Ideally, I'd also like to do the inverse and take a Flow SID and discover any Inbound Phone Numbers which use that Flow for their Voice actions. The Flow resource doesn't appear to have this information at all, so it would appear I have to get all the Inbound Phone Numbers and loop through pulling out the SIDs for those items using a matching Flow SID. Is there a better way?
What you have described is the best way to work here. When you make a call to a Twilio phone number, Twilio makes webhook requests to the URL that is set as their voice_url
. In the UI, we can show that as a Studio Flow, a Function, or a TwiMLBin, but under the hood it's just a URL. So, to find out which Flow your number is pointing at, you will need to check the voice_url
and parse out the Flow SID, which is that last part of the URL, FWXXX
.
For the other way around, there is no way to find out the numbers that are pointing at a Flow from the Flow. You will need to list all your Inbound Phone Numbers and loop through, as you described.