# How to Setup a Test Environment

In this documentation, you will learn:

* [How to set up a **test environment** for the Calling API](#initial-setup)
* [How to **create a SIP extension** for testing](#create-a-sip-extension)
* [How to configure **SIP trunks** (inbound and outbound) to connect with Meta](#id-3-creating-a-sip-trunk)
* [How to check and adjust **Asterisk SIP settings**](#id-4-checking-asterisk-sip-settings)
* [How to configure **inbound and outbound routes**](#id-5-inbound-outbound-routes)
* [How to test calls using MicroSIP and monitor logs via **Asterisk CLI**](#id-6-testing-the-calls)
* [Troubleshooting tips for common issues during setup](#troubleshooting)

## Initial setup

We’ll use the SIP method to integrate with the Calling API. For this setup, you can either create your own virtual private server (VPS) or use an existing test environment.

{% hint style="info" %}
In our example, we chose a [VPS from Hostinger](https://www.hostinger.com/vps-hosting), which provides a server with FreePBX pre-installed. FreePBX is an essential tool for managing SIP connections and simplifies the configuration and management of VoIP services.
{% endhint %}

Below are the tools you will need:

* [x] Test server (VPS, EC2, or other)
* [x] FreePBX with Asterisk
* [x] Softphone software (MicroSIP)

## Configuring the server

Now that you already have everything to start, let’s configure the environment:

{% stepper %}
{% step %}

### Create a SIP extension

In FreePBX, an extension represents a user or device within the system.

For this setup, the extension will represent the user who will connect through a softphone application — in our case, MicroSIP.

#### When creating the extension:

* [x] **Enable the TLS transport** to ensure secure communication between the client and the server.
* [x] Make sure to note the **username** and **password**, as they will be required when configuring the softphone later.
  {% endstep %}

{% step %}

### Creating a SIP Trunk <a href="#id-3-creating-a-sip-trunk" id="id-3-creating-a-sip-trunk"></a>

A **SIP Trunk** in FreePBX is a **virtual connection** that **links** your **FreePBX system to external networks**, such as a telephone service provider or another PBX system.

In this integration, **the trunk will connect your FreePBX server directly to Meta**, **enabling** the **Calling API to route calls** between WhatsApp and your test environment.

To properly handle call flows, you need to create two separate trunks:

* [x] **Inbound Trunk** – Handles calls coming from Meta to your FreePBX system.
* [x] **Outbound Trunk** – Handles calls going from your FreePBX system to Meta.

This separation ensures that each call direction can be configured and monitored independently, providing better control and easier troubleshooting.

{% hint style="info" %}
When naming your trunks, use clear and descriptive labels such as <mark style="color:$success;">**`Meta-Inbound`**</mark> and <mark style="color:$success;">**`Meta-Outbound`**</mark>.&#x20;

This will make it easier to identify them later when setting up routes or checking logs.
{% endhint %}

When creating the trunks:

* [x] Disable the authentication parameter for the Inbound trunk.
* [x] For the Outbound trunk, set the credentials generated by Meta in the authentication parameter.
  {% endstep %}

{% step %}

### Checking Asterisk SIP Settings <a href="#id-4-checking-asterisk-sip-settings" id="id-4-checking-asterisk-sip-settings"></a>

**Asterisk** is the core software engine that FreePBX uses to **handle all the actual call processing.** FreePBX is essentially a user-friendly interface that sits on top of Asterisk, making it much easier to configure and manage.

{% hint style="info" %}

#### Important notes:

* You don’t need to change anything in the General SIP Settings.
* Make sure that you’re using the correct certificate in the SSL settings and select TLSv1.2 in the SSL Method.
* Confirm that the TLS transport is enabled and listening on port 5061. It must match the port configured in the calling settings.
  {% endhint %}
  {% endstep %}

{% step %}

### Inbound/Outbound Routes <a href="#id-5-inbound-outbound-routes" id="id-5-inbound-outbound-routes"></a>

We’re approaching the end of our implementation: now, we just need to **configure the routes**, and then you’re ready to start testing the Calling API.
{% endstep %}

{% step %}

### Testing the Calls <a href="#id-6-testing-the-calls" id="id-6-testing-the-calls"></a>

Now you´re able to go to the MicroSIP softphone software and add the Extensions using the **name** and the **secret** (password) **generated in step 1**.

<table><thead><tr><th width="236.5999755859375" align="center">Account name</th><th width="259">Calling Inbound</th></tr></thead><tbody><tr><td align="center"><strong>SIP Server</strong></td><td>VPS public IPv4 address</td></tr><tr><td align="center"><strong>Username</strong></td><td>Extension username</td></tr><tr><td align="center"><strong>Password</strong></td><td>Extension secret</td></tr><tr><td align="center"><strong>Domain</strong></td><td>VPS hostname/IPv4 address</td></tr><tr><td align="center"><strong>Media Encryption</strong></td><td>Mandatory SRTP (RTP/SAVP)</td></tr><tr><td align="center"><strong>Transport</strong></td><td>TLS</td></tr><tr><td align="center"><strong>Allow IP Rewrite</strong></td><td>True</td></tr></tbody></table>

After that, you can make a user-initiated call and/or get the permissions and start a business-initiated call.
{% endstep %}
{% endstepper %}

## Troubleshooting

It’s important to **test calls directly through the terminal** to **verify** that the **configuration is working** as expected.

By monitoring the logs in real time, you can:

* Confirm that the calls are correctly established between FreePBX and Meta.
* Identify **errors** or **warnings** that may indicate misconfigurations or connection issues.
* Gather detailed information about SIP messages and call flow for troubleshooting.

{% hint style="info" %}

#### **Tip:**

Use the Asterisk CLI command below to start monitoring logs:

```
asterisk -rvvv
```

During a test call, look for any failed registrations, authentication errors, or SIP negotiation problems.\
This information will help you determine the root cause of any issue and make the necessary adjustments before moving forward.
{% endhint %}

If you have other issues or doubts, please contact our support team:&#x20;

[Get support](/docs/support/get-support.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.360dialog.com/docs/messaging/calling/how-to-setup-a-test-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
