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: Sun Mar 06, 2016 3:55 pm    Post subject: [Freeswitch-users] Mod_sms and script to send to Twilio Reply with quote

Hi all.

I wrote a small Python script that is run from a chatplan and takes a chat
message from a sip extension and sends the message to the appropriate phone
number via Twilio (they provide an Internet-based API to do this). The
script works great, but I still see an error in on fs_cli console:




I've tried mucking with the "to" and "to_user" headers (and other headers
as well). I've also tried adding the following line in the chatplan XML
file:



Finally, I've tried different return values in the Python script.

Nothing I've tried removes the error messages. In truth, the texting works
fine -- I just don't like seeing the error.

Here's my chatplan XML file:


And the python script:


I'm new to the world of SIP and Freeswitch, so I am hoping I am missing
something simple.

Any help is appreciated.






--
View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Mod-sms-and-script-to-send-to-Twilio-tp7596204.html
Sent from the freeswitch-users mailing list archive at Nabble.com.

_________________________________________________________________________
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
rtreleaven at bunnykic...
Guest





PostPosted: Sun Mar 06, 2016 3:58 pm    Post subject: [Freeswitch-users] Mod_sms and script to send to Twilio Reply with quote

I think the console message and the script are missing from you email.

On Sat, Mar 5, 2016 at 3:29 PM, drodrig <drodrig@magicbrain.com (drodrig@magicbrain.com)> wrote:
Quote:
Hi all.

I wrote a small Python script that is run from a chatplan and takes a chat
message from a sip extension and sends the message to the appropriate phone
number via Twilio (they provide an Internet-based API to do this). The
script works great, but I still see an error in on fs_cli console:




I've tried mucking with the "to" and "to_user" headers (and other headers
as well). I've also tried adding the following line in the chatplan XML
file:



Finally, I've tried different return values in the Python script.

Nothing I've tried removes the error messages. In truth, the texting works
fine -- I just don't like seeing the error.

Here's my chatplan XML file:


And the python script:


I'm new to the world of SIP and Freeswitch, so I am hoping I am missing
something simple.

Any help is appreciated.






--
View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Mod-sms-and-script-to-send-to-Twilio-tp7596204.html
Sent from the freeswitch-users mailing list archive at Nabble.com.

_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting@freeswitch.org (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 (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
mike at jerris.com
Guest





PostPosted: Wed Mar 09, 2016 5:20 pm    Post subject: [Freeswitch-users] Mod_sms and script to send to Twilio Reply with quote

remove the punctuation from the number....

Quote:
On Mar 8, 2016, at 1:09 PM, David Rodrigues <drodrig@magicbrain.com> wrote:

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


_________________________________________________________________________
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