Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
--! @usage
-- forward incoming message to some extension
-- <action application="lua" data="sms_forward.lua '${from}' ''" />
local function escape(s)
s = string.gsub(s, '\\', '\\\\')
s = string.gsub(s, '|', '\\|')
return s
local from = assert(argv[1])
local to = assert(argv[2])
local type = message:getHeader('type') or 'text/plain'
local body = message:getBody() or ''
local api = freeswitch.API()
local result = api:execute('chat', table.concat({
'sip', escape(from), escape(to), escape(body), escape(type)
}, '|'))
local msg = string.format('[sms_forward] message(%s) `%s`/`%s` forwarded to `%s`/`%s`: %s\n',
message:getHeader('from') or '----',
message:getHeader('to') or '----',
from, to, result
local level = (result == 'Sent') and 'debug' or 'err'
freeswitch.consoleLog(level, msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.