FreeSWITCH IVR in Lua calls and executes Nodejs code

Source: Internet
Author: User
Tags http post lua freeswitch

First, functional requirements:

The corresponding script file is called through the FreeSWITCH IVR key, and Nodejs provides many modules, which can easily communicate with other systems or in any form, my application is to send HTTP POST requests via Nodejs;

Because I'm not familiar with the way freeswitch directly transfers the execution of the Nodejs file, I execute a LUA script that executes a call to the Nodejs file in a LUA script and executes it with the following specific settings:

Second, the specific setting:

①IVR settings:

<entry action= "Menu-exec-app" digits= "1" param= "Lua Testlighton.lua"/>
②testlighton.lua Script content:

Os.execute (' node/usr/local/freeswitch/scripts/lighton.js '); Nodejs File storage location:/usr/local/freeswitch/scripts/lighton.js

③/usr/local/freeswitch/scripts/lighton.js Script content:

var rest = require (' Restler ');

Rest.post (' Http://192.168.11.17:3021/serviceUp/cmd/sendCMDDispatcher ', {
Data: {
cmdcontent:[{
' Deviceentityaid ': ' 03003c00 ',
' Dataid ': ' 03010000 ',
"Value": "FF"
}]
},
}). On (' Complete ', function (data, response) {
Console.log (data);
}). On (' Error ', function (er) {
Console.log (ER);
});

This allows the HTTP POST request to be implemented according to the "1" button in the IVR prompt, where the data area is transmitted in the body.

    

FreeSWITCH IVR in Lua calls and executes Nodejs code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.