Caller ID is the information that arrives with a phone call in order to display who is calling on your phone or that special device you have from the phone company. In the world of the
PSTN what is transmitted from where the person is calling to where it is arriving is really just their phone number, then the local provider does a lookup in a database to find the name to pass it along to you on that last mile.
In the world of
VoIP, when receiving calls from your VoIP provider, many times you will only get the phone number and will need to do that
Reverse Phone Lookup yourself. To this end I created a Ruby Library,
Whitepages, that may be plugged into
Adhearsion to perform this lookup for you.
To use the Whitepages gem in an Adhearsion application you may simply create a new
component and drop this code in (don't forget you need a
Whitepages API Key):
[sourcecode language='ruby']
require 'whitepages'
#Create an object that authenticates with our API key to the Whitepages
#Web service
::WHITEPAGES = Whitepages.new(COMPONENTS.reverse_phone_lookup[:api_key])
methods_for :dialplan do
def reverse_phone_lookup(phone_number)
#Query an entry based on phone
data = ::WHITEPAGES.reverse_phone({ "phone" => phone_number.to_s })
end
end
[/sourcecode]
Then drop this in your Adhearsion dialplan:
[sourcecode language='ruby']
adhearsion {
caller_details = reverse_phone_lookup(callerid)
ahn_log.reverse_phone_lookup caller_details
}
[/sourcecode]
Then, when you get a call you may not only see who is calling, but even plot them on a map if you wanted to. A wealth of information is available that you may see
here.
Again, with the wealth of data and APIs available combined with Adhearsion, you imagination is the limit.