Skip to content

Commit a165cd8

Browse files
Added SWML example for Call forwarding guide
* Created SWML guide for Call forwarding * Created SWML guide for Call forwarding * Minor adjustments * Minor adjustments * Various grammatical changes * Update website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx --------- Co-authored-by: August <[email protected]>
1 parent cfd803a commit a165cd8

File tree

1 file changed

+60
-15
lines changed
  • website/docs/main/home/calling/voice/getting-started/how-to-forward-calls

1 file changed

+60
-15
lines changed

website/docs/main/home/calling/voice/getting-started/how-to-forward-calls/index.mdx

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,64 @@ description: Use cXML to forward calls
88

99
# Forwarding Calls
1010

11-
In [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx) we learned how to use XML
12-
bins to define what should happen when a call is received by one of your
11+
In [Making and Receiving Phone Calls](/voice/getting-started/making-and-receiving-phone-calls) we learned how to use SWML and cXML
12+
to define what should happen when a call is received by one of your
1313
SignalWire numbers. In that case, we just played some audio. In this article,
1414
instead, we will use the same technique to forward the call to a different
1515
number.
1616

1717

18-
## cXML for Call Forwarding
18+
## SWML for call forwarding
1919

20-
We are going to define the forwarding instructions in an cXML bin hosted on
21-
SignalWire. To create a new cXML bin, navigate to the "Resources" section from your sidebar. There, create
22-
a new script, and select the "cXML" option.
20+
We are going to define the forwarding instructions in a SWML Script hosted on SignalWire.
21+
To create a new SWML Script, navigate to the **Resources** section from your sidebar.
22+
There, create a new Script, and select the **SWML Script** option.
2323

24-
Create a new cXML bin, and paste the following XML in it:
24+
### Creating your call forwarding Script
25+
26+
Once you are in the menu for creating a SWML Script, copy and paste the following Script:
27+
28+
```yaml andJson
29+
version: 1.0.0
30+
sections:
31+
main:
32+
- connect:
33+
from: "%{call.from}"
34+
to: "+15551234567"
35+
```
36+
37+
This Script will handle the call by making an outbound dial, setting the `from` address to be the address which created the initial call,
38+
and then forwarding that call to the number specified in the `to` field.
39+
40+
:::info
41+
You should replace `+15551234567` with a real phone number, for example your personal one.
42+
:::
43+
44+
We used the [`connect`](/swml/methods/connect) method to call the number you would like the call to be forwarded to.
45+
Notice how we used its `from` parameter to ensure that the number of the original caller
46+
(stored in the [`call.from` variable](/swml/variables/#field-from))
47+
is maintained as caller ID for the forwarded call.
48+
49+
### Assigning the Script to a SignalWire Phone Number
50+
51+
The final step is to configure one of your SignalWire phone numbers to answer calls using the SWML Script we just created.
52+
You can do that from the **Phone Numbers** section:
53+
54+
![Assign Resource](@image/dashboard/phone-numbers/assign-resource-voice.png)
55+
56+
After clicking on the **Phone Numbers** section, click on the phone number that you'd like to assign, then click **edit settings**.
57+
From there, click **Assign Resource** and assign the newly created SWML Script.
58+
Now any calls that are routed to that number will be forwarded, with the caller ID being the original number that called in.
59+
60+
## cXML for call forwarding
61+
62+
We are going to define the forwarding instructions in a cXML Script hosted on SignalWire.
63+
To create a new cXML Script, navigate to the **Resources** section from your sidebar.
64+
There, create a new Script, and select the **cXML Script** option.
65+
66+
### Creating your call forwarding Script
67+
68+
Create a new cXML Script, and paste the following XML in it:
2569

2670
```xml
2771
<?xml version="1.0" encoding="UTF-8"?>
@@ -30,34 +74,35 @@ Create a new cXML bin, and paste the following XML in it:
3074
</Response>
3175
```
3276

33-
You should replace `123-456-7891` with a real phone number, for example your
34-
personal one.
77+
:::info
78+
You should replace `123-456-7891` with a real phone number, for example your personal one.
79+
:::
3580

3681
We used the [`<Dial>`](/compatibility-api/cxml/voice/dial) verb to call the number you
3782
would like the call to be forwarded to. Notice how we used its `callerId` attribute to ensure that the
38-
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
83+
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
3984
templating system and how it works in our [dedicated guide](/compatibility-api/guides/general/utilizing-mustache-templates).
4085

4186
import NewLegacy from '/docs/main/_common/dashboard/_ui-accordion.mdx'
4287

4388
<NewLegacy />
4489

45-
If you're still on **Legacy UI**, refer to [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx) for detailed instructions.
90+
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.
4691

47-
## Assigning the Bin to a SignalWire Phone Number
92+
### Assigning the Script to a SignalWire Phone Number
4893

49-
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:
94+
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:
5095

5196
![Assign Resource](@image/dashboard/phone-numbers/assign-resource-voice.png)
5297

53-
Refer to [Making and Receiving Phone Calls](../making-and-receiving-phone-calls/index.mdx#receiving-incoming-calls) for more information about this step.
98+
Refer to [Making and Receiving Phone Calls](/voice/getting-started/making-and-receiving-phone-calls#receiving-incoming-calls) for more information about this step.
5499

55100
## Conclusion
56101

57102
You are now ready to test call forwarding.
58103

59104
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.
60105

61-
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
106+
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
62107
flexibility and real-time control on your calls, you may be interested in our
63108
guide about how to [make and receive calls in Node.js](/sdks/realtime-sdk/guides/voice/first-steps-with-voice).

0 commit comments

Comments
 (0)