Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] Mod_sms and script to send to Twilio


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
drodrig at magicbrain.com
Guest





PostPosted: Tue Mar 08, 2016 3:05 pm    Post subject: [Freeswitch-users] Mod_sms and script to send to Twilio Reply with quote

Thank you. I'm new to the mailing list. I had my mail client set for
html. Perhaps that was the problem. Here is the Python script:

#/usr/bin/env python

import re
import pprint
import sys
import urllib
import subprocess

from freeswitch import *

ACCOUNTSID = 'my-account-sid'
AUTHTOKEN = 'my-auth-token'
PHONENUMBER = '+my-source-phone-number'

def chat(message, args):
to_phone = '+1' + re.sub('\D', '',
urllib.unquote(message.getHeader('to_user'))).lstrip('+1')
body = message.getBody()
subprocess.call("curl -X POST
'https://api.twilio.com/2010-04-01/Accounts/'" + ACCOUNTSID +
"/Messages.json --data-urlencode 'To=" + to_phone + "'
--data-urlencode " +
"'From=+" + PHONENUMBER + "' --data-urlencode 'Body=" + body
+ "' -u " +
ACCOUNTSID + ":" + AUTHTOKEN, shell=True)

Here is my chatplan XML file:

<?xml version="1.0" encoding="utf-8"?>
<include>
<context name="public">
<extension name="100">
<condition field="to" expression="^(.*)$">
<action application="python" data="sms"/>
</condition>
</extension>
</context>
</include>

And here is the error (keep in mind that the script actually works
fine. I receive the SMS as expected):

2016-03-05 15:17:54.040913 [DEBUG] mod_python.c:286 Finished calling
python script
2016-03-05 15:17:54.040913 [WARNING] sofia_presence.c:221 Not sending
to local box for (XXX)%CX%A0XXX-XXX@my.sipdomain.com <-- (Note that I
substituted Xs for the actual phone digits just for this post)
2016-03-05 15:17:54.040913 [ERR] sofia_presence.c:272 Chat proto [sip]
from ["d100" <sip:100@my.sipdomain.com>;tag=0b2cec63]
to [(XXX)%CX%A0XXX-XXX@my.sipdomain.com]
Test sms
Nobody to send to: Profile internal

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services