<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I got it working! The goal was to run a script to inform users via a text message when they get a voicemail.</div><div>This script looks for a &quot;vm-notify-sms&quot; param in the user&#39;s directory information. It sends the text from user&#39;s outbound caller-ID number, which is set in the standard FS configuration. I&#39;m using the SMS API from Flowroute.com.</div><div><br></div><div>--[[ This script is called by configuration in autoload_configs/lua.conf.xml.</div><div>     It is called on a &quot;vm:maintenance&quot; event.</div><div>]]</div><div><br></div><div>-- The following is specifc to the Flowroute SMS API,</div><div>-- documented at <a href="https://developer.flowroute.com/docs/messaging">https://developer.flowroute.com/docs/messaging</a></div><div>url = &quot;<a href="https://api.flowroute.com/v2/messages">https://api.flowroute.com/v2/messages</a>&quot;</div><div>authentication = &quot;user:password&quot;</div><div><br></div><div>action = event:getHeader(&quot;VM-Action&quot;)</div><div>if action ~= &quot;leave-message&quot; then return end</div><div>user = event:getHeader(&quot;VM-User&quot;)</div><div>domain = event:getHeader(&quot;VM-Domain&quot;)</div><div>caller_id_name = event:getHeader(&quot;VM-Caller-ID-Name&quot;)</div><div>caller_id_number = event:getHeader(&quot;VM-Caller-ID-Number&quot;)</div><div>--[[ We don&#39;t care about these:</div><div>file_path = event:getHeader(&quot;VM-File-Path&quot;)</div><div>flags = event:getHeader(&quot;VM-Flags&quot;)</div><div>folder = event:getHeader(&quot;VM-Folder&quot;)</div><div>uuid = event:getHeader(&quot;VM-UUID&quot;)</div><div>--]]</div><div>message_len = event:getHeader(&quot;VM-Message-Len&quot;)</div><div>timestamp = event:getHeader(&quot;VM-Timestamp&quot;)</div><div>api = freeswitch.API();</div><div>from = api:execute(&quot;user_data&quot;, user .. &quot;@&quot; .. domain ..  &quot; var outbound_caller_id_number&quot;)</div><div>to = api:execute(&quot;user_data&quot;, user .. &quot;@&quot; .. domain .. &quot; param vm-notify-sms&quot;)</div><div>if to == &quot;&quot; then return end</div><div><br></div><div>if caller_id_name == &#39;&#39;</div><div>        or caller_id_name == &#39;UNKNOWN&#39;</div><div>        or caller_id_name == &#39;UNASSIGNED&#39;</div><div>        or caller_id_name == &#39;WIRELESS CALLER&#39;</div><div>        or caller_id_name == &#39;TOLL FREE CALL&#39;</div><div>        or caller_id_name == &#39;Anonymous&#39;</div><div>        or caller_id_name == &#39;Unavailable&#39;</div><div>        then caller_id_name = nil end</div><div>if caller_id_number == &#39;&#39;</div><div>        then caller_id_number = nil end</div><div>message = &quot;Voicemail &quot;</div><div>if caller_id_name</div><div>        then message = message .. &quot;from &quot; .. caller_id_name .. &quot; (&quot; ..  caller_id_number .. &quot;)&quot;</div><div>        elseif caller_id_number</div><div>        then message = message .. &quot;from &quot; .. caller_id_number end</div><div>message = message .. &quot; at &quot; .. os.date(&quot;%I:%M %p&quot;, timestamp)</div><div>message = message .. &quot; length &quot; .. message_len .. &quot; seconds&quot;</div><div>message = message .. &quot; to box &quot; .. user</div><div>message = message .. &quot;.&quot;</div><div>-- Blindly send the text</div><div>data = &#39;{ &quot;to&quot;: &quot;&#39; .. to .. &#39;&quot;, &quot;from&quot;: &quot;&#39; .. from .. &#39;&quot;, &quot;body&quot;: &quot;&#39; .. message .. &#39;&quot;}&#39;</div><div>--[[</div><div>     Until either Freeswitch has the ability to pass authentication data</div><div>     to the mod_curl API (FS-9223), or the Flowroute API has the ability</div><div>     to take authentication data in the POST body (they are working on it),</div><div>     we are forced to spawn a shell to use the curl from our OS.</div><div>]]</div><div>-- api.execute(&quot;curl&quot;, url .. &quot; auth &quot; .. authentication .. &quot; post &quot; .. data)</div><div>os.execute(&quot;curl -u &quot; .. authentication .. &quot; -H &#39;Content-Type: application/json&#39; -X POST -d &#39;&quot; .. data .. &quot;&#39; &quot;  .. url)</div><div><br></div></div></div></div>