2
votes

We would like inbound calls to display both a display name and the phone number on our phone displays. For calls coming from Twilio, the Dial verb has a CallerID attribute, but that doesn't result in the SIP From header being formed correctly.

Our OnSIP hosted PBX needs the SIP header to look something like this:

From: "Display Name" <sip:[email protected]>

If I just put in a phone number in the callerId attribute like this:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial timeout="90" callerId="3605551212">
        <Sip>sip:[email protected]</Sip>
    </Dial>
</Response>

then the SIP From header looks like this:

From: "+13605551212" <sip:[email protected]>

I want to replace the number in quotes with a display name, generated from the CallerName field from Twilio's caller ID lookup.

Does the Twilio Dial verb or SIP noun provide a way to form the SIP From header in this way?

1

1 Answers

1
votes

Unfortunately there is no way to have the calling name in the From field and have the calling number in the URI:

From: "Display Name" <sip:[email protected]>

We can add the cname to the callerId field and this will overwrite both.

From: "gonzalo" <sip:[email protected]>

What about adding a custom header with the calling number/called name?

@app.route("/voice", methods=['GET', 'POST'])
def handle_incoming_call():
    from_number = request.values.get('From')
    cname = request.values.get('CallerName')
    cname = cname.strip()
    print from_number
    print cname

    try:
        resp = twilio.twiml.Response()
        d = resp.dial()
        d.sip('sip:[email protected]?Twiml-cname=' +  cname)
        print resp
        return str(resp)

    except Exception as e:
        print str(e)

This will add a header like this, maybe they can just grab it using a LUA script and put it in the From header:

X-Twiml-cname: GASCA+GONZALO