Search code examples
asteriskagifastagi

Send Sip Message through fastagi asterisk


I am able to relay messages using dialplan. This command sends the message but I cant seem to run it using fastagi(java)

DialPlan

exten => _X.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})

FastAgi

public void service(AgiRequest ar, AgiChannel ac) throws AgiException {
    System.out.println(ac.getFullVariable("${MESSAGE(body)}"));
    System.out.println(ac.getFullVariable("${MESSAGE(to)}"));
    System.out.println(ac.getFullVariable("${MESSAGE(from)}"));
    System.out.println(ac.getFullVariable("${CUT(MESSAGE(to),@,1)}"));
    //Correct values are show from above printlns
    ac.exec("MessageSend(${CUT(MESSAGE(to),@,1)},${MESSAGE(from)})");
}

Last line results in a warning in /var/asterisk/messages

WARNING[2287][C-00000000] res_agi.c: Could not find application (MessageSend(${CUT(MESSAGE(to),@,1)})


Solution

  • Figured it out, this is how it is done in fastagi

    ac.exec("MessageSend","sip:100,<sip:[email protected]:5080>");
    

    Documentation for MessageSend https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Application_MessageSend