How to handle calls from a subaccount to the task router + workers on the main account on Twilio

How to handle calls from a subaccount to the task router + workers on the main account on Twilio
typescript
Ethan Jackson

I have the following scenario here:

  • all of our clients phone's and agents are currently on the main account and we want to have our call center on the main account and all of our clients phone's on subaccounts.
  • we want to have all of our clients on subaccounts so we can properly calculate the billing for each one of them

I tried to:

  • create a task from the subaccount to the parent account: no success.
  • create a conference from a subaccount inbound call and add agents to it: no success.
  • simply dial from the subaccount to the main account: it worked but all additional data was lost.

Answer

The solution I found it was just to return a voice response with Dial().Application(): https://www.twilio.com/docs/voice/twiml/dial/application#basic-usage

app = VoiceResponse().dial().application(application_sid='AP****00', copy_parent_to=True, customer_id=phone.customer_id) # your additional data here to bind the original callsid app.parameter(name='OriginalCallSid', value=data.CallSid) app.parameter(name='OriginalAccountSid', value=data.AccountSid)

You've got to:

  1. Set an application event handler on the app settings in order to enqueue the call on your new account.

  2. Allow the application to receive calls from other apps.

The app call back will provide all that data on the body post.

Hope that helps.

Related Articles