FusionPBX SMS Integration with Bandwidth

Status
Not open for further replies.

mak_make

Member
Aug 27, 2018
53
0
6
42
Maybe we have to work on the V2 and convert the code according to it. I found some info from Bandwidth about V1 vs V2 this might shed some light on the changes that we have to make:

 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
Hey guys,

Sorry to be a pain (newbie on sms), but I am getting nowhere with this. I have my bandwidth account.
I followed the https://github.com/fusionpbx/fusionpbx-apps/blob/master/sms/README.md page to get the sms stuff installed.
I did have to go and fix the permissions /var/www/fusionpbx/app/sms back to www-data:www-data.
I have filled in the bandwidth_key and bandwidth_secret. I have set the url to be https://messaging.bandwidth.com/api/v2/users/XXXXXX/messages. All three are marked as True.
I have added the IP for messaging.bandwidth.com to the domains allow section of ACL.
In my Bandwidth Application, I have set the Callback URL to https://<my server DNS name>/app/sms/hook/sms_hook_bandwidth.php
I left Use a username/password for callbacks unchecked.

I have updated the sms_hook_bandwidth.php to the latest version that was posted with the last modification by @inder.singh

I can see my incoming text messages getting to Bandwidth, but I don't see Fusion looking for them. Is there something I need to do to make it reach out to Bandwidth to get them?
For sending, I get: SMS chatplan no actions found
Is there an additional dialplan or something that needs to be made?

Thanks for the help,
Robert
 

mak_make

Member
Aug 27, 2018
53
0
6
42
Hi Robert,

We required to add a filed called "application id" to your index.lua file? where is your index.lua file located?

can you post the error.log
 
Jan 9, 2018
152
16
18
54
I'll let @inder.singh or @mak_make weigh in on the inbound, but in general, no, FusionPBX doesn't have to reach out. They get pushed to FusionPBX by the carrier, and then the scripts in FusionPBX are responsible for either sending it via email and/or delivering it to the endpoint. It sounds like it's getting to you, but there's something wrong with the delivery to the endpoint. You can review your /var/log/nginx/error.log to see what's happening. Or your freeeswitch logs to see if it is attempting the delivery to the endpoint.

Regarding outbound, what do you have for /etc/freeswitch/chatplan/default.xml? At least one of the actions in it needs to look like:
XML:
<action application="lua" data="app.lua sms outbound"/>

Since I only allow 10-digit recipients, I have this section that handles those:
XML:
                <extension name="ten-digit">
                        <condition field="to" expression="^(\d{10}.*)$">
                                <action application="set" data="final_delivery=true"/>
                                    <action application="lua" data="app.lua sms outbound"/>
                        </condition>
                </extension>
That's within my "public" context section.
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
OK. I do remember seeing someting about that.

I find 2 locations:
./var/www/fusionpbx/app/sms/resources/install/scripts/app/sms/index.lua
./usr/share/freeswitch/scripts/app/sms/index.lua

What needs to be added?

Thanks,
Robert
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
For the chatplan file, I believe mine is the default as I haven't edited it. Here is the contents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<include>
        <context name="default">
                <extension name="demo">
                        <condition field="to" expression="^(.*)$">
                                <!-- <action application="lua" data="test.lua"/> -->
                                <!-- <action application="reply" data="Hello, you said: ${_body}"/> -->
                        </condition>
                </extension>
        </context>  
        <context name="public">
                <extension name="demo">
                        <condition field="to" expression="^(.*)$">
                                <!-- <action application="lua" data="app.lua sms outbound"/> -->
                        </condition>
                </extension>
        </context>
</include>

Thanks,
Robert
 

mak_make

Member
Aug 27, 2018
53
0
6
42
Robert,

The outbound message uses the path ./usr/share/freeswitch/scripts/app/sms/index.lua for sending outbound. in the Index file you have to add the application filed at carrier Bandwidth section


PHP:
cmd="curl -v -X POST " .. api_url .." -u " .. access_key .. ":" .. secret_key .. " -H \"Content-type: application/json\" -d '{\"from\": \"+" .. outbound_caller_id_number .. "\", \"to\": \"+" .. to .."\", \"text\": \"" .. body .."\", \"applicationId\": \"place your application ID here\"}'"

 
Jan 9, 2018
152
16
18
54
Here's what I use for my "public" context section:
XML:
        <context name="public">
                <extension name="ten-digit">
                        <condition field="to" expression="^(\d{10}.*)$">
                                <action application="set" data="final_delivery=true"/>
                                    <action application="lua" data="app.lua sms outbound"/>
                        </condition>
                </extension>
        <extension name="unreg">
              <condition field="${sofia_contact(profile/${to})}" expression="error\/user_not_registered">
                                <action application="set" data="final_delivery=true"/>
                        </condition>
        </extension>
                <extension name="allowed-local">
            <condition field="from_host" expression="domain.number1.com|domain.number2.com" >
                                <action application="set" data="final_delivery=true"/>
                                <action application="info"/>
                                <action application="send"/>
                        </condition>
                </extension>
                <extension name="other">
                        <condition field="to" expression="^(.*)$">
                                <action application="set" data="final_delivery=true"/>
                                <!-- <action application="send"/> -->
                        </condition>
                </extension>
        </context>
This blocks on-net messaging except for the list of domains you specify. It also avoids sending to an unregistered extension.

At very least, in the "public" context section, replace the <extension></extension> bit with what I showed in the previous message.
 
Jan 9, 2018
152
16
18
54
Robert,
Note that the tips @mak_make and I are giving you are related to outbound. As far as inbound, it really depends on your error.log as to what's happening when Bandwidth tries to send to you.
 

mak_make

Member
Aug 27, 2018
53
0
6
42
Robert,

As @Jonathan Black said it's depends on your error.log. It might be an ACL issue as the Bandwidth send inbound messages from various IP Addresses. below are the list of IP addresses I got from Bandwidth. If its a ACL issue then once you add the below in your ACL then you should start receiving inbound messages.

The IP addresses are

18.233.250.246
3.82.123.96
52.72.24.132
54.203.195.28
54.212.144.187
54.213.231.6
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
SUCCESS!!!! Woohoo. I can send out now. Thanks for the help on that.

Incoming is still not working. Would I check the freeswitch log for incoming issues or the nginx log for the issues?

Thanks,
Robert
 

mak_make

Member
Aug 27, 2018
53
0
6
42
Robert,

Make sure the DID# in the SMS Destination Matches the DID# in the voicemail settings SMS To field. I use the format as 1XXXXXXXXXX.
 

Robert Birch

Member
Mar 16, 2017
111
5
18
53
I don't see anything in my nginx access or error logs for bandwidth.com.
I do have the servers I get from DNS (I'm in canada so I think my bandwidth.com servers are different), but I did also try allowing 0.0.0.0/0 (this is a test server) just to see, and I still get nothing in the logs.

Is it possible I have something configured wrong in the Application on Bandwidth?

@mak_make
I believe I have the SMS section configured in Fusion correctly.
Under Applications/SMS - Created an entry.
Destination is: 1xxxxxxxxxx
Carrier: bandwidth
Extension: 101 (my extension)
Enabled: True

I set my Outbound Caller ID Number to the same 11 digit number (1xxxxxxxxxx) which I believe is to allow outgoing, which is working.

Do I need to create a Destination for text messages?

Thanks,
Robert
 

mak_make

Member
Aug 27, 2018
53
0
6
42
under SMS tab at MDR's are you seeing any records? Did you check fs_cli to while you are sending incoming message?
 
Jan 9, 2018
152
16
18
54
Check your nginx access.log and see if you are seeing any activity when you send a message in. If you are not seeing anything in either nginx log, then I’d review your webhook URL settings on Bandwidth. Also, try accessing the webhook url yourself to make sure it is accurate (you should get some response, or at least show an access attempt in the access.log)
 
Status
Not open for further replies.