diff --git a/website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx b/website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx index 116e550af..b4af29915 100644 --- a/website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx +++ b/website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx @@ -8,20 +8,62 @@ description: Use cXML to forward calls # Forwarding Calls -In [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx) we learned how to use XML -bins to define what should happen when a call is received by one of your +In [Making and Receiving Phone Calls](/voice/getting-started/making-and-receiving-phone-calls) we learned how to use SWML and cXML +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. -## cXML for Call Forwarding +## SWML for call forwarding -We are going to define the forwarding instructions in an cXML bin hosted on -SignalWire. To create a new cXML bin, navigate to the "Resources" section from your sidebar. There, create -a new script, and select the "cXML" option. +We are going to define the forwarding instructions in a SWML Script hosted on SignalWire. +To create a new SWML Script, navigate to the **Resources** section from your sidebar. +There, create a new Script, and select the **SWML Script** option. -Create a new cXML bin, and paste the following XML in it: +### Creating your call forwarding Script + +Once you are in the menu for creating a SWML Script, copy and paste the following Script: + +```yaml andJson +version: 1.0.0 +sections: + main: + - connect: + from: "%{call.from}" + to: "+15551234567" +``` + +This Script will handle the call by making an outbound dial, setting the `from` address to be the address which created the initial call, +and then forwarding that call to the number specified in the `to` field. + +:::info +You should replace `+15551234567` with a real phone number, for example your personal one. +::: + +We used the [`connect`](/swml/methods/connect) method to call the number you would like the call to be forwarded to. +Notice how we used its `from` parameter to ensure that the number of the original caller (stored in the `call.from` variable) is maintained as caller ID for the forwarded call. + +### Assigning the Script to a SignalWire Phone Number + +The final step is to configure one of your SignalWire phone numbers to answer calls using the SWML Script we just created. +You can do that from the **Phone Numbers** section: + +![Assign Resource](@image/dashboard/phone-numbers/assign-resource-voice.png) + +After clicking on the **Phone Numbers** section, click on the phone number that you'd like to assign, then click **edit settings**. +From there, click **Assign Resource** and assign the newly created SWML Script. +Now any calls that are routed to that number will be forwarded, with the caller ID being the original number that called in. + +## cXML for call forwarding + +We are going to define the forwarding instructions in a cXML Script hosted on SignalWire. +To create a new cXML Script, navigate to the **Resources** section from your sidebar. +There, create a new Script, and select the **cXML Script** option. + +### Creating your call forwarding Script + +Create a new cXML Script, and paste the following XML in it: ```xml @@ -30,27 +72,28 @@ Create a new cXML bin, and paste the following XML in it: ``` -You should replace `123-456-7891` with a real phone number, for example your -personal one. +:::info +You should replace `123-456-7891` with a real phone number, for example your personal one. +::: We used the [``](/compatibility-api/cxml/voice/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 +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](/compatibility-api/guides/general/utilizing-mustache-templates). import NewLegacy from '/docs/main/_common/dashboard/_ui-accordion.mdx' -If you're still on **Legacy UI**, refer to [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx) for detailed instructions. +If you're still on **Legacy UI**, refer to [Making and Receiving Phone Calls](/voice/getting-started/making-and-receiving-phone-calls) for detailed instructions. -## Assigning the Bin to a SignalWire Phone Number +### Assigning the Script 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: +The final step is to configure one of your SignalWire phone numbers to answer calls using the cXML Script we just created. You can do that from the **Phone Numbers** section: ![Assign Resource](@image/dashboard/phone-numbers/assign-resource-voice.png) -Refer to [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx#receiving-incoming-calls) for more information about this step. +Refer to [Making and Receiving Phone Calls](/voice/getting-started/making-and-receiving-phone-calls#receiving-incoming-calls) for more information about this step. ## Conclusion @@ -58,6 +101,6 @@ 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](/compatibility-api/guides/voice/general/setting-up-call-whispering-in-cxml) 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 +SWML and cXML Scripts 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](/sdks/realtime-sdk/guides/voice/first-steps-with-voice).