Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions website/docs/main/_common/dashboard/create-cxml-script.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<TabItem value="newui" label="New Dashboard">

If you're on the **new UI**, go to the "Resources" section from the sidebar, and create a new Resource.
In the new resource picker, select "Script" and create a "cXML script".
If you're on the **new UI**, go to the **Resources** section from the sidebar, and create a new Resource.
In the new resource picker, select **Script** and create a **cXML script**.

<Frame>
![Attach Phone Number](@image/dashboard/resources/new-cxml-bin.png)
Expand All @@ -13,7 +13,7 @@

<TabItem value="legacyui" label="Legacy Dashboard">

If you're on the **Legacy UI**, go to the "cXML/LaML" section in your [SignalWire Space](https://signalwire.com/signin), then click on "Bins", and create a new script.
If you're on the **Legacy UI**, go to the **cXML/LaML** section in your [SignalWire Space](https://signalwire.com/signin), then click on **Bins**, and create a new script.

<Frame>
![Legacy bin](@image/dashboard/legacy/xml-bins.png)
Expand Down
6 changes: 3 additions & 3 deletions website/docs/main/_common/dashboard/create-swml-script.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<TabItem value="newui" label="New Dashboard">

To create a SWML Script in the **new UI**, go to the "Resources" section from the sidebar, and create a new Resource.
In the new resource picker, select "Script" and create a "SWML Application".
To create a SWML Script in the **new UI**, go to the **Resources** section from the sidebar, and create a new Resource.
In the new resource picker, select **Script** and create a **SWML Application**.

<Frame>
![Attach Phone Number](@image/dashboard/resources/swml-resource-vid.webp)
Expand All @@ -13,7 +13,7 @@

<TabItem value="legacyui" label="Legacy Dashboard">

If you are using the **Legacy UI**, go to the "Relay/SWML" section in your sidebar, then click on the "SWML Scripts" tab. Click on "Create a SWML Script",
If you are using the **Legacy UI**, go to the "Relay/SWML" section in your sidebar, then click on the **SWML Scripts** tab. Click on **Create a SWML Script**,
and then give it a name and pass it some instructions. You can use the following as a starting point:

<Frame>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To be able to make calls, you will need:

To acquire a phone number, [Log in](https://signalwire.com/signin) to your SignalWire Space. From the [Phone Numbers section](https://my.signalwire.com/?phone_numbers), you can [buy a new phone number](/platform/phone-numbers/getting-started/buying-a-phone-number). You will need at least one number to make and receive calls.

For what concerns your API credentials, find these in the API section of your Space, as shown in the following figure. You may need to create a new token if you never used one. Make sure that your token has the "Voice" scope enabled.
For what concerns your API credentials, find these in the API section of your Space, as shown in the following figure. You may need to create a new token if you never used one. Make sure that your token has the **Voice** scope enabled.

<Frame caption="You can find your Project ID and Token from the API tab in your SignalWire Space. Make sure your token has the 'Voice' scope enabled.">

Expand All @@ -54,12 +54,12 @@ import NewLegacy from '/docs/main/_common/dashboard/_ui-accordion.mdx'
To handle incoming calls we need to configure the phone number in our
[SignalWire Space](https://signalwire.com/signin) to answer calls using a SWML Script.

To create a SWML Script in the **new UI**, go to the "Resources" section from the sidebar, and create a new Resource.
In the new resource picker, select "Script" and create a "SWML Application".
To create a SWML Script in the **new UI**, go to the **Resources** section from the sidebar, and create a new Resource.
In the new resource picker, select **Script** and create a **SWML Application**.


If you are using the **Legacy UI**, go to the "Relay/SWML" section in your sidebar, then click on the "SWML Scripts" tab. Click on "Create a SWML Script",
and then give it a name and pass it some instructions. You can use the following as a starting point:
If you are using the **Legacy UI**, go to the **Relay/SWML** section in your sidebar, then click on the **SWML Scripts** tab.
Click on **Create a SWML Script*, and then give it a name and pass it some instructions. You can use the following as a starting point:

```yaml andJson
version: 1.0.0
Expand All @@ -68,9 +68,11 @@ sections:
- play: say:Hello from SignalWire!
```

Take note of the Request URL for the SWML Script that we created. You can even create a new script if you want to define a different behavior for incoming calls.
Take note of the Request URL for the SWML Script that we created.
You can even create a new script if you want to define a different behavior for incoming calls.

To configure your number to handle incoming calls with an SWML Script, click the ["Phone Numbers" section](https://my.signalwire.com/?phone_numbers) within your SignalWire Space, and edit the settings of the specific number you would like to use to answer calls. Set "Handle calls using" to "a SWML Script", then select your SWML Script from the dropdown:
To configure your number to handle incoming calls with an SWML Script, click the [**Phone Numbers**](https://my.signalwire.com/?phone_numbers) section within your SignalWire Space, and edit the settings of the specific number you would like to use to answer calls.
Set **Handle calls using** to **a SWML Script**, then select your SWML Script from the dropdown:

That's it! Inbound calls to this SignalWire number will execute the specified SWML Script.

Expand All @@ -84,10 +86,10 @@ We want to call a number and play an audio message which says "Welcome to
SignalWire. This is my first call". We are going to define this behavior in an
XML bin, which is used to declare what should happen during a call.

If you're on the **new UI**, go to the "Resources" section from the sidebar, and create a new Resource.
In the new resource picker, select "Script" and create a "cXML script".
If you're on the **new UI**, go to the **Resources** section from the sidebar, and create a new Resource.
In the new resource picker, select **Script** and create a **cXML script**.

If you're on the **Legacy UI**, go to the "cXML/LaML" section in your [SignalWire Space](https://signalwire.com/signin), then click on "Bins".
If you're on the **Legacy UI**, go to the **cXML/LaML** section in your [SignalWire Space](https://signalwire.com/signin), then click on **Bins**.

Create a new bin, and paste the following XML in it:

Expand Down Expand Up @@ -133,15 +135,15 @@ To handle incoming calls we need to configure the phone number in our
[SignalWire Space](https://signalwire.com/signin) to answer calls using a cXML
bin.

If you're on the **new UI**, go to the "Phone Numbers" section from the sidebar, and
If you're on the **new UI**, go to the **Phone Numbers** section from the sidebar, and
edit the phone number you want to answer calls from. There, click on the
"Assign Resource" button for incoming calls, and select the cXML or SWML script you'd like to connect.
**Assign Resource** button for incoming calls, and select the cXML or SWML script you'd like to connect.

If you're on the **old UI**, take note of the Request URL for the bin that we created in the previous
section. You can even create a new bin if you want to define a different
behavior for incoming calls.

Click the "Phone Numbers" section from your sidebar, and select the specific number you would like to use to answer calls. The same number we used before can work.
Click the **Phone Numbers** section from your sidebar, and select the specific number you would like to use to answer calls. The same number we used before can work.

Make sure that "_Accept Calls As_" is set to "_Voice Calls_", "_Handle Calls Using_" is set to "_LaML Webhooks_", and paste your Bin URL in as the value for "_When a Call Comes In_". Click "_Save_", and you're done! Inbound calls to this SignalWire number will execute the specified bin.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,59 +63,72 @@ sections:

Take note of the Request URL for the SWML Script that we created. You can even create a new script if you want to define a different behavior for incoming calls.

To configure your number to handle incoming calls with an SWML Script, click the ["Phone Numbers" section](https://my.signalwire.com/?phone_numbers) within your SignalWire Space, and edit the settings of the specific number you would like to use to answer calls. Set "Handle calls using" to "a SWML Script", then select your SWML Script from the dropdown:
To configure your number to handle incoming calls with an SWML Script, click the [Phone Numbers](https://my.signalwire.com/?phone_numbers) section within your SignalWire Space, and edit the settings of the specific number you would like to use to answer calls.
Set **Handle calls using** to **a SWML Script**, then select your SWML Script from the dropdown

That's it! Inbound calls to this SignalWire number will execute the specified SWML Script.

## Compatibility API

### Making your first call

You now have all you need to make your first call, for example to your personal phone number.

We want to call a number and play an audio message which says "Welcome to
SignalWire. This is my first call". We are going to define this behavior in a
cXML bin, which is used to declare what should happen during a call.

<CreateCXML />
Outbound calls can be made via the SignalWire REST API's [Create a Call endpoint](/rest/signalwire-rest/endpoints/calling/call-commands).
This is accomplished by sending a POST request using SWML in the request body to handle the call.
The SWML can be served via URL or passed inline directly.

Create a new bin, and paste the following XML in it:
<Tabs>
<TabItem value="URL" label="URL">

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to SignalWire. This is my first call.</Say>
</Response>
```bash
curl -L -g 'https://Your_Space_Name.signalwire.com/api/calling/calls' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic YOUR-PROJECT-ID:YOUR-API-TOKEN' \
--data-raw '{
"command": "dial",
"params": {
"from": "sip:from-sip@example-112233445566.sip.signalwire.com",
"to": "+1xxxxxxxxxx",
"caller_id": "+1234567890",
"fallback_url": "https://example.com/fallback",
"status_url": "https://example.com/status_callback",
"status_events": [
"answered",
"ended"
],
"url": "https://example.com/swml"
}
}'
```

The XML above uses the [&lt;Say>](/compatibility-api/cxml/voice/say)
verb to play a text-to-speech message. Save the bin and take note of its Request
URL.

You are now ready to start the call using cURL:
</TabItem>
<TabItem value="inline" label="inline SWML">

```bash
curl -L -X POST 'https://{SpaceName}.signalwire.com/api/laml/2010-04-01/Accounts/{ProjectID}/Calls' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Accept: application/json' \
-u '{ProjectID}:{APIToken}' \
--data-urlencode 'Url=https://{BinRequestURL}' \
--data-urlencode 'From={+XXXXXXXXXX}' \
--data-urlencode 'To={+YYYYYYYYYY}'
curl -L -g 'https://Your_Space_Name.signalwire.com/api/calling/calls' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic YOUR-PROJECT-ID:YOUR-API-TOKEN' \
--data-raw '{
"command": "dial",
"params": {
"from": "sip:from-sip@example-112233445566.sip.signalwire.com",
"to": "+1xxxxxxxxxx",
"caller_id": "+1234567890",
"fallback_url": "https://example.com/fallback",
"status_url": "https://example.com/status_callback",
"status_events": [
"answered",
"ended"
],
"swml": "{'version':'1.0.0','sections':{'main':[{'play':'say:Hello from SignalWire!'}]}}"
}
}'
```

Make sure to replace all occurrences of `{SpaceName}`, `{ProjectID}`,
`{APIToken}`, `{BinRequestURL}`, `{+XXXXXXXXXX}`, and `{+YYYYYYYYYY}` with
your actual values.

:::note
</TabItem>
</Tabs>

Instead of your own bin, feel free to try one of ours: `<https://<spacename>.signalwire.com/laml-bins/f85376be-7fe1-439b-a24f-3113ff980804>`.

:::

Congratulations! Once the cURL request is executed, your personal phone number
(`{+YYYYYYYYYY}`) will start ringing.
## Compatibility API

### Receiving incoming calls

Expand All @@ -125,10 +138,27 @@ Congratulations! Once the cURL request is executed, your personal phone number
To handle incoming calls we need to configure the phone number in our
[SignalWire Space](https://signalwire.com/signin) to answer calls using a cXML
resource.

If you're on the **new UI**, go to the **Resources** section from the sidebar, and create a new Resource.
In the new resource picker, select **Script** and create a **cXML script**.

<Frame>
![Attach Phone Number](@image/dashboard/resources/new-cxml-bin.png)
</Frame>

If you're on the **new UI**, go to the "Phone Numbers" section from the sidebar, and
edit the phone number you want to answer calls from. There, click on the
"Assign Resource" button for incoming calls, and select the cXML or SWML script you'd like to connect.
Utilize the following cXML which uses the [&lt;Say>](/compatibility-api/cxml/voice/say)
verb to play a text-to-speech message:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to SignalWire. This is my first call.</Say>
</Response>
```

Go to the **Phone Numbers** section from the sidebar, and
edit the phone number you want to answer calls with. From there, click on the
**Assign Resource** button for incoming calls, and select the newly created cXML script to connect.

<Frame>
![Attach Resource](@image/dashboard/phone-numbers/assign-resource-voice.png)
Expand All @@ -141,14 +171,19 @@ Congratulations! Once the cURL request is executed, your personal phone number
To handle incoming calls we need to configure the phone number in our
[SignalWire Space](https://signalwire.com/signin) to answer calls using a SWML or cXML script.

Take note of the Request URL for the bin that we created in the previous
section. You can even create a new bin if you want to define a different
behavior for incoming calls.
Utilize the following cXML which uses the [&lt;Say>](/compatibility-api/cxml/voice/say)
verb to play a text-to-speech message:

Click the "Phone Numbers" section from your sidebar, and select the specific number you would like to use to answer calls. The same number we used before can work.
```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to SignalWire. This is my first call.</Say>
</Response>
```
Click the **Phone Numbers** section from your sidebar, and select the specific number you would like to use to answer calls. The same number we used before can work.

Make sure that "_Accept Calls As_" is set to "_Voice Calls_", "_Handle Calls Using_" is set to "_LaML Webhooks_" or "_SWML Scripts_",
and paste your Bin URL in as the value for "_When a Call Comes In_". Click "_Save_", and you're done!
Make sure that "_Accept Calls As_" is set to "_Voice Calls_", "_Handle Calls Using_" is set to "_LaML Webhooks_" or "_SWML Scripts_",
and paste your Bin URL in as the value for "_When a Call Comes In_". Click "_Save_", and you're done!
Inbound calls to this SignalWire number will execute the specified bin.

<Frame>
Expand All @@ -158,6 +193,36 @@ Congratulations! Once the cURL request is executed, your personal phone number
</TabItem>
</Tabs>

### Making your first call

To call a number via cXML you can make a POST request to the Compatibility REST API's [Create a Call](/rest/compatibility-api/endpoints/create-a-call) endpoint.

```bash
curl -L -X POST 'https://{SpaceName}.signalwire.com/api/laml/2010-04-01/Accounts/{ProjectID}/Calls' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Accept: application/json' \
-u '{ProjectID}:{APIToken}' \
--data-urlencode 'Url=https://{BinRequestURL}' \
--data-urlencode 'From={+XXXXXXXXXX}' \
--data-urlencode 'To={+YYYYYYYYYY}'
```

Make sure to replace all occurrences of `{SpaceName}`, `{ProjectID}`,
`{APIToken}`, `{BinRequestURL}`, `{+XXXXXXXXXX}`, and `{+YYYYYYYYYY}` with
your actual values.

In order to locate the `{BinRequestURL}`, navigate to your cXML script and copy the Request URL that is present.


:::note

Instead of your own bin, feel free to try one of ours: `<https://<spacename>.signalwire.com/laml-bins/f85376be-7fe1-439b-a24f-3113ff980804>`.

:::

Congratulations! Once the cURL request is executed, your personal phone number
(`{+YYYYYYYYYY}`) will start ringing.



# Wrapping up
Expand Down