Make API calls directly from Lua code

From FreeSWITCH Wiki
Jump to: navigation, search

Discussion

When calling a Lua script from the dialplan you always have the session object. However, Lua can also be called from the CLI. In either case, it is possible to execute API commands from within Lua by creating an API object:

api = freeswitch.API();
reply = api:executeString("version");

In the above snippet, the Lua variable reply would receive the version number from FreeSWITCH.

You can do more intricate things as well, like this:

api = freeswitch.API();
sofia = api:executeString("sofia status");

The Lua variable sofia would contain the total output of the sofia status command.

Examples

See Also

mod_lua