Asterisk and Synapse EHR

Discussion in 'Asterisk FreePBX PBX in a Flash' started by Graham, Apr 22, 2012.

  1. Graham

    Graham Developer Staff Member

    I now have an experimental beta version of Synapse EHR that uses Asterisk to initiate outbound telephone calls. When the called party picks up, your own extension then rings allowing you to complete the connection. It uses Asterisk call files. See http://www.the-asterisk-book.com/unstable/call-file.html

    To get this working, you need to install rebol on your Asterisk/PBX in a flash box.

    Install rebol following this link http://www.rebol.com/download-core.html so in the linux shell logged in as root

    Code:
    wget http://www.rebol.com/downloads/v278/rebol-core-278-4-3.tar.gz
    tar -xzf rebol-core-278-4-3.tar.gz
    Then change to the directory: \releases\rebol-core
    Code:
    cd releases
    cd rebol-core
    Copy the rebol interpreter (rebol) to /bin
    Code:
    cp rebol /bin
    Check that it works by typing

    Code:
    rebol
    and the interpreter will come up. Type: quit (to quit the intepreter.)

    You now need to install a cgi script in the apache cgi-bin directory.

    On my centos build, it is /var/www/cgi-bin/ so

    Code:
    cd /var/www/cgi-bin/
    wget http://synapsebeta.s3.amazonaws.com/callback.cgi
    chmod +x callback.cgi
    
    Code:
    cd /var/www/cgi-bin/
    wget http://synapsebeta.s3.amazonaws.com/call-both.cgi
    chmod +x call-both.cgi
    
    You can now use the script from a PC inside your network ( no way should apache be exposed to public )

    http://5.213.119.35/cgi-bin/callback.cgi?extension=100&MaxRetries=2&RetryTime=60&waittime=30&context=from-pstn&priority=2&channel=SIP/VFX/1234567

    where here the number being called is 1234567, and the channel is SIP/VFX, and my extension that asterisk should call once it connects is 100.
    Jason likes this.
  2. Graham

    Graham Developer Staff Member

    The CGI script works by decoding all the parameters required to create the Asterisk call file. It then creates the file in /var/spool/asterisk/tmp with a random name. It is then chown asterisk:asterisk name-of-file.call so that Asterisk can use it. And then it is moved to the /var/spool/asterisk/outgoing/ directory where it is picked up and run as a script by Asterisk.

    At present there is no checking of the dialled numbers so if you don't want staff making international calls on your coin, you will have to wait until the script is secured. I am presuming call files bypass dial rules which would otherwise prevent abuse.
  3. Jason

    Jason Developer / Handyman Staff Member

    The possibilities of integrating EHR + Telephone is endless.
    This is very cool.
  4. Graham

    Graham Developer Staff Member

    I've uploaded beta-89beta with this functionality. In settings/user/sms & telephony change the settings but they won't stick. I'm not adding to preferences until I'm sure it works reliably. At present it has my settings so it won't work for you ... you'll have to change it each time you load up Synapse.
  5. Graham

    Graham Developer Staff Member

    Updated so that you can save your settings to your dropbox folder. It will reload automatically when you call a number.
    When testing on my own phones, it works, but when I tried it on other phones got silent phone so will have to see this can be fixed.
  6. Jason

    Jason Developer / Handyman Staff Member

    synapse.the.real.nextgen.jpg

    Can't wait to try this.
  7. Graham

    Graham Developer Staff Member

    To secure this script, I could easily add
    • userid and password for international calls
    • user code to just log who calls (like photocopier accounts )
    • parse rules to block international calls
    • email to admin each time it is used
    • etc.
    No point of doing this until I am sure this is going to work.
  8. Graham

    Graham Developer Staff Member

    I have created some dial rules using Rebol's parse feature to allow some calls and block others.
    You will have to alter the script to use your own rules.
  9. Graham

    Graham Developer Staff Member

    Limited testing seems to work ...and of course, if I get blocked, I can revert to manually dialling ;)
  10. Jason

    Jason Developer / Handyman Staff Member

    Updated the first post:
    - added some Linux Newbie things (ie. cd releases, cp rebol, etc.)
    - added call-both.cgi instructions.
  11. Jason

    Jason Developer / Handyman Staff Member

    My SMS & Telephony settings
    synapse.FreePBX.asterisk.SMS.Telephony.settings.jpg

    To make a Call from Synapse.
    Asterisk.Calling.from.Synapse.jpg

    Click [Call Now] to execute the call.
    synapse.asterisk.call.now.jpg
  12. Jason

    Jason Developer / Handyman Staff Member

    I get this error from a PC of mine.
    I am going to check the server settings.

    Code:
    make object! [
      code: 505
      type: 'access
      id: 'invalid-spec
      arg1: 192.168.1.140/cgi-bin/callback.cgi?Channel=ZAP%2F1%2F955555555&Extension=731&MaxRetries=2&RetryTime=60&WaitTime=30&Context=from-zaptel&Priority=1
      arg2: none
      arg3: none
      near: [result: read dialstring
      parse result
      ]
      where: 'on-click
  13. Jason

    Jason Developer / Handyman Staff Member

    Code:
    http://192.168.1.199/cgi-bin/callback.cgi?Channel=ZAP%2F1%2F9059059051&Extension=777&MaxRetries=2&RetryTime=60&WaitTime=30&Context=from-pstn&Priority=1
    The script gives me errors but manually typing it in seems to work.
  14. Graham

    Graham Developer Staff Member

    Odd. It says Invalid spec suggesting that the protocol is wrong.
  15. Jason

    Jason Developer / Handyman Staff Member

  16. Graham

    Graham Developer Staff Member

    I'm looking to see how viable it might be to integrate Amazon's Alexa at present.
    Jason likes this.
  17. Jason

    Jason Developer / Handyman Staff Member

    Do you have one ?
  18. Graham

    Graham Developer Staff Member

    Yes. I got it working in the weekend to control my lights but I was thinking I could get it to do appointments for me etc.

    I bought an Echo Dot. And I'll be buying more so that I have them in the other rooms of the house.

Share This Page