Group of Adhearsion apps for Presence that includes variable callerid and a RESTful click to call webservice
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
config
drb_service
init.d
log
rest_webservice
.ahnrc
.gitignore
README
Rakefile
dialplan.rb

README

Presence AHN Tools - v0.10

- Applications
	- Variable CallerID
	- RESTful Click-to-Call Webservice for PBX only calls

=====

- Application Notes for Variable CallerID

This Adhearsion application provides a mechanism for adding the SIP Header
'P-Assert-Identity' which may be used to relate a custom CLI from the database
on a call by call basis. The application works in the following way:

1. On an outbound dial an AGI is called before the Dial command in extensions.conf
2. That AGI then makes a request to the Adhearsion server running on a TCP socket
3. Adhearsion then looks up CLI details from the database as follows:
	- Obtains the prefix from the extension dialed (ie - 93134153331212, it would take 
	313 to do the lookup)
	- Looks up the prefix in PCO_OUTBOUNDSERVICE in field PHONEPREFIX
	- Takes the outbound service name returned and splits by the '|' (ie - 'SERVICE NAME | 4155551212')
	- Adds a SIP Header using the first field as the name and the second filed as the number 
4. You may invoke asserted-identity/drb_service/refresh_cache.rb with 'ruby refresh_cache.rb' to 
manually refresh the cache
5. You may also now start the DRb Service as a *NIX daemon:
	- ruby daemonize_drb_service.rb run
	- ruby daemonize_drb_service.rb start
	- ruby daemonize_drb_service.rb stop
	- ruby daemonize_drb_service.rb restart
6. Or as init.d scripts
	- /etc/init.d/drb_service start
	- /etc/init.d/adhearsion start
	- /etc/init.d/rest_webservice start
7. Or as init.d scripts
	- /etc/init.d/drb_service start
	- /etc/init.d/adhearsion start
	- /etc/init.d/rest_webservice start
8. It is possible to configure the app to either do a SipAddHeader directly over AGI, or to set
variables and allow the Asterisk extensions.conf Dialplan to set the SipAddHeader
	- May be toggled by setting this in asserted-policy/config/config.yml:
		  - Options are:
		    - CALLERID - Using the equivalent of 'Set(CALLERID=)
		    - SIPADDHEADER - Use SipAddHeader
		    - VARIABLES - Use the channel variables ASSERTED_NAME & ASSERTED_NUMBER
				- ASSERTED_NAME == CallerID Name
				- ASSERTED_NUMBER == CallerID Number
8. It is also possible to configure a SIP From Domain in the SipAddHeader step:
	- CustomConfig = { :assert_type => 'SIPADDHEADER', :from_domain => '@compassknowledge.com' }
	
These considerations must be made when configuring the environment for this application:

1. Modify the database settings and cache timeout in path_to_project/config/config.yml
2. The Outbound Service must always use a Prefix including the Switch Prefix 
3. The prefix used must always be 3 digits long
4. The Outbound Service name must always follow this format: NAME | 4155551212
5. Do not forget to strip out the prefix before doing the dial in the Asterisk outbound context
6. This app uses Distributed Ruby (http://rubyurl.com/93vN), so you must always start up the 
application in this sequence:
	- First run 'ruby path_to_project/drb_service/drb_service.rb'
	- Then Adhearsion per the below
	
*Consideration for testing:

Currently the system does adds a SIP Header (http://gist.github.com/17486) as follows:

P-Asserted-Identity: BURGERSHACK<sip:4155551212>

=====

- Application Notes for RESTful Click-to-Call Web Service

The web service may be invoked as follows:

http://localhost:4567/call/destination=4155551212&source=303&serviceid=8000

*The context for the PBX-Click-to-Call should be as follows:

[local_click_to_call]
exten => _X.,1,Dial(SIP/${EXTEN})@trunk)
exten => _X.,n,Hangup
;Context for the customer connection
[destination_click_to_call]
exten => _X.,1,AGI(agi://localhost)
exten => _X.,n,Dial(SIP/${EXTEN:4}@trunk||r)
exten => _X.,n,Hangup

A screencast may be seen here:

http://video.google.com/a/presenceco.com/?tab=mv#/Play/contentId=908fa999b299309e

=====

- Adhearsion Notes

Start your new app with "ahn start /path/to/your/app"

If you wish to use Adhearsion to control Asterisk's dialplan,
change the contexts you wish to be affected in your
/etc/asterisk/extensions.conf file to the following:

[your_context_name]
exten => _X.,1,AGI(agi://1.2.3.4) ; This IP here