Forwarding Calls
In Making and Receiving Phone Calls we learned how to use XML bins to define what should happen when a call is received by one of your SignalWire numbers. In that case, we just played some audio. In this article, instead, we will use the same technique to forward the call to a different number.
XML for Call Forwarding
We are going to define the forwarding instructions in an XML bin hosted on SignalWire. To create an XML bin, go to the "LaML" section in your SignalWire space, then click on "Bins".
Create a new bin, and paste the following XML in it:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="{{From}}">123-456-7891</Dial>
</Response>
You should replace 123-456-7891
with a real phone number, for example your
personal one.
We used the <Dial>
verb to call the number you
would like the call to be forwarded to. Notice how we used its callerId
attribute to ensure that the
number of the original caller (stored in the From
variable) is maintained as caller id for the forwarded call. You can read more about the
templating system and how it works in our dedicated guide.
Assigning the Bin to a SignalWire Phone Number
The final step is to configure one of your SignalWire phone numbers to answer calls using the XML bin we just created. You can do that from the "Phone Numbers" section:
Refer to Making and Receiving Phone Calls for more information about this step.
Conclusion
You are now ready to test call forwarding.
If you are forwarding calls to a personal number, you may wonder how to differentiate incoming calls as either personal or ones forwarded from your SignalWire number. Please see our guide on Call Whisper for a handy solution.
XML bins offer a quick and easy way to get started with common use cases. If you are an advanced developer, or you need more flexibility and real-time control on your calls, you may be interested in our guide about how to make and receive calls in Node.js.