skip to Main Content

I’m building a Twillio-like Dialer API using Modesl in Node.JS to send commands and parameters to Freeswitch Console.

Edit: I’ve narrowed down the issue to a syntax issue, where the javascript I’m using to input my variables are conflicting with FreeSwitchs syntax.
uuid_send_dtmf needs to have a ‘ in front of it, whereas uuid is a NodeJS parameter that needs to be passed after one space, as is dmtf, and the api_on_answer requires a ‘ for closing after my parameters are passed.

Syntax has always been my weak point, any help would be greatly appreciated.

,api_on_answer='uuid_send_dtmf ' + uuid  + ' ' + dmtf +' ' }
    conn.api('originate {
                  origination_uuid=' + uuid 
                  + ',origination_caller_id_number=' + cid 
                  + ',api_on_answer=uuid_send_dtmf ' + uuid  
                  + ' ' + dmtf +' }
              sofia/external/' + pnumber + '@provider', function(res) {

Currently the command is giving a very vague error of little help:

2019-03-17 08:53:22.755065 [DEBUG] switch_ivr_originate.c:2204 Parsing global variables
2019-03-17 08:53:22.755065 [ERR] switch_ivr_originate.c:2209 Parse Error!
2019-03-17 08:53:22.755065 [DEBUG] switch_ivr_originate.c:3941 Originate Resulted in Error Cause: 27 [DESTINATION_OUT_OF_ORDER]

What is the correct way to do what I need?

2

Answers


  1. Chosen as BEST ANSWER

    Fixed using '' to input ' inline.

    var onanswer = ''' + uuid + ' ' + dmtf;


  2. try this,

    conn.api(`originate {origination_uuid=${uuid},origination_caller_id_number=${cid},api_on_answer='${uuid_send_dtmf} ${uuid} ${dtmf}'}sofia/external/${pnumber}@${provider}`, function(res) {
    

    template literals or strings, enclosed by back-ticks, this would provide you the required format, cheers 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search