{% assign signature  = QueryString.signature %}

{% assign results = RawBody | Split:'&' %}
{% assign body = Dictionary %}

{% for result in results %}
    {% assign resultParts = result | Split:'=' %}
    {% assign body = body | AddToDictionary:resultParts[0],resultParts[1] %}
{% endfor %}
{% assign to = body.To | UrlDecode %}
{% if signature != 'YOUR_RANDOM_SIGNATURE_NUMBER' %}
<Response><Reject reason="rejected"/></Response>
{% else %}
    {% systemphonenumber where:'Number == "{{ to }}"' securityenabled:'false' limit:'1' disableattributeprefetch:'true' %}
        {% assign systemphonenumber = systemphonenumberItems | First %}
        {% assign person = systemphonenumber.AssignedToPersonAlias.Person %}
        {% assign phone = person | PhoneNumber:'Mobile','true' %}
        {% if phone == null %}
            {% assign phone = 'Global' | Attribute:'OrganizationPhone' %}
        {% endif %}
        {% assign formattedPhone = phone | Remove:'(' | Remove:')' | Remove:'-' | Remove:' ' | Trim  %}
        {% if formattedPhone contains '+1' %}
            {% comment %}Rock doesn't have a does not contains.{% endcomment %}
        {% else %}
            {% assign formattedPhone = formattedPhone | Prepend:'+1' %}
        {% endif %}
    {% endsystemphonenumber %}
<Response>
      <Dial>
        <Number>{{ formattedPhone }}</Number>
      </Dial>
</Response>
{% endif %}
