Why SMS sending is failing using plivo in R? - r

I am trying to use R script to send SMS internationally. I am using correctly Auth ID and Token, both numbers are verified. But I haven't bought any number from "Plivo". Is this the reason my message is not sent?
The code is getting compiled without any error. But no SMS is sent or received. I am sharing my code below:
#!/usr/bin/env Rscript
library(httr)
AUTH_ID="**************"
AUTH_TOKEN="**************************"
message<-"Eddie is confirming the message"
url="https://api.plivo.com/v1/Account/**************/Message/"
POST(url,authenticate(AUTH_ID,AUTH_TOKEN),body=list
(src="+966123456789",dst="+4912345678910",text=message))
Can anybody please tell me that what could be the possible reasons that why message sending is not happening even the source code is correct?

But I haven't bought any number from "Plivo"
The answer is:
To send an SMS with Plivo, you need a Plivo bought number.
Obvious logic:
If this was not the case, anyone could send messages from any "verified" phone numbers?
If you meant verified as in "account verified":
This is not what Plivo is used for, you need to check if your Mobile Carrier is providing an accessible internet accessible API (I doubt it.) If you need to use sim-linked numbers, you can always use modems and AT commands, but it's fairly unreliable.
I think you should buy a $1 Plivo number, unless you need it to validate gmails or things of such.

Related

Quectel BG96 MQTT publish error

I'm try to publish my data to ThingsBoard server i use this types of AT commands
AT+QIACT=1
OK
AT+QMTOPEN=1,"demo.thingsboard.io",1883
OK
AT+QMTCONN=1,"demo.thingsboard.io","MY_ACCESS_TOKEN",""
OK
AT+QMTPUB=1,0,0,0,"v1/devices/me/telemetry"
>{"temperature":35.00,"humidity":80.00} // MY_POST_DATA This line hanging my module
All AT commands response is ok But i finally enter MY_POST_DATA the module doesn't provide no response hanging the previous command.. and i check my ThinksBoard data never post telemetry..
Please help any one how can i fix this problem and publish MQTT server.
Step 1: Get hold of the official AT command documentation for the modem (Quectel BG96 I assume?). It should document how the AT+QMTPUB command behaves and what it expects. Everything else is just guessing. The manufacturer should provide this, and if not you should demand to get one.
...
Step 873, when you have exhausted absolutely all possible ways of getting hold of the official AT command documentation for the modem: You can try my guess that the command behaves similar to other commands that read arbitrary length user data, most notably AT+CMGS which sends SMS messages, which expect a Ctrl-Z (ascii value 26) as an end of data indicator.
+QMTPUB: 1,0,0 simply mean that BG96 has successfully published and your broker (thingsboard) have also acknowledged publication of message.
If you can't see data on broker, then please check if the topic you are publishing is correct or not.
It may happen you are publishing to another topic (or to a different PATH).
Ask 'thingsboard' for help regarding proper topic.

Setup R alert when long process is Finished

I'm running a really long process and it would be great if there was a way to get R to Call, Email or Text me when its finished. Is there a way to setup an R-email script to be run when a program terminates or perhaps something that might employ IFTTT to send me a text message or Call in case I'm sleeping.
I'm using RStudio as my IDE so maybe there is such a feature through there.
If there is a way to track progress that would be nice too, but not 100% required
From this article:
http://alicebrawley.com/getting-r-to-notify-you-when-its-finished/
My general solution is to combine the R package mail, written by Lin
Himmelmann, and variations on an IFTTT (If This, Then That) recipe. I
use mail to send an email using functions in R, then IFTTT to notify
me immediately of that particular email.
Once you’ve installed mail, use the following functions to send
yourself an email when your code is completed.
#Have R email you when it's done running.
###Calculating - your wish is R's command.
library(mail)
#Send yourself an email - specify your preferred email address, subject, and message. The password is fixed at "rmail".
sendmail("xxxxx#xxxxx.com", subject="Notification from R", message="Conditions finished running!", password="rmail")
You can then use IFTT triggered by the email.
If you're sleeping next to your computer, consider also: Is there a way to make R beep/play a sound at the end of a script?

How to send a text from the user's cell phone number using Twilio?

I want to programatically send SMS / text messages from my Meteor app; many people recommend twilio for this, and there are several Meteor Twilio packages (findable via atmosphere and/or googling/binging). I don't know if one of these packages is decidedly better than the other, but for now, at least, I'm using the abhiaayer:meteor-twilio package.
My concern is that, when you create a Twilio account, they assign you a "from" phone number (you can't, apparently, just use your own). Maybe I'm misunderstanding how this works, but before I go too far down this path, I want to know if the sender of the SMS -- IOW the user of my app -- will be able to use their phone number as the "from"/sender phone number.
After all, the whole point of my app is to allow the user to send out multiple identical texts (such as "where are you?" or "are you okay?") to friends/family, and then get a response back from them (to his phone, not to a Twilio-supplied number).
If it's possible to use Twilio with your own phone number as the "from"/sending number, has anyone got suggestions on Meteor package preferences (abhiaayer, andreioprisan, DispatchMe) and how that can be accomplished from Meteor?
I imagine the basic code would be pretty much the same, regardless of package used; e.g., here's an example from the andreioprisan package
twilio = Twilio(ACCOUNT_SID, AUTH_TOKEN);
twilio.sendSms({
to:'+16515556677', // Any number Twilio can deliver to
from: '+14506667788', // A number you bought from Twilio and can use for outbound communication
body: 'word to your mother.' // body of the SMS message
}, function(err, responseData) { //this function is executed when a response is received from Twilio
if (!err) { // "err" is an error received during the request, if any
// "responseData" is a JavaScript object containing data received from Twilio.
// A sample response from sending an SMS message is here (click "JSON" to see how the data appears in JavaScript):
// http://www.twilio.com/docs/api/rest/sending-sms#example-1
console.log(responseData.from); // outputs "+14506667788"
console.log(responseData.body); // outputs "word to your mother."
}
});
I did create a Twilio account, and have the "from" number (not my actual cell phone number) they assigned my account, and the SID, but I don't kow what the AUTH_TOKEN should be.
If what I intend is not possible from Twilio, what I may do is just write the app so that all the selected "to" numbers can be copied to the clipboard, so that the user can paste them into his SMS screen's "recipients" textbox; but I was hoping to afford the user the luxury of simply tapping a button.
I don't think you can do this (send from the user's own cell number using Twilio). If your app is an actual mobile app as opposed to a web app you can use the Android or iOS APIs for sending SMS from the user's phone. I'm not sure of the details of this and certainly with iOS it looks like you can't do so fully automatically for obvious reasons (you could just spam all the user's contacts for instance, and this would incur a monetary cost to the user).
There's a Cordova plugin here which can do what you want: https://github.com/cordova-sms/cordova-sms-plugin (I haven't used it so can't vouch for it but it seems to be actively maintained).
If it is a web app, your suggesting of copying the numbers to clipboard is by far the most straightforward solution and I would recommend that in the first instance. For completeness I've included some details and considerations below of how you can do 2-way communication with Twilio (or alternatives such as Nexmo) in a couple of ways, in case someone finds it helpful. It's not exactly trivial though. 1-way communication is a lot easier!
Send via API
From your app the user types a message and selects who to send it to. You app then connects to your server which uses the Twilio API to send N messages to the N recipients. These messages will appear to come from the Twilio-provided number.
Send via SMS
The user manually sends an SMS to your Twilio number and then you receive a webhook to your server from Twilio with the message details. You have to do the processing to work out who to forward the message to and then use the Twilio API to do so. Again the recipients will see a message from the Twilio-provided number.
Replies
When a recipient replies to the message, Twilio sends you a webhook with the details and you can determine who sent the original message and forward the reply back to the original sender.
Number Pooling
One of the obvious flaws here is that if multiple users send a message to the same person then there's no way of telling which message they are replying to. There's no message IDs passed with SMS so you have to use multiple sending numbers (one per unique sender to a particular recipient). The amount of numbers required is basically the most number of different senders one user would have to reply to (this is not generally possible to work out beforehand, so you would have to call the API to provision a new number on the fly).
To give a more concrete example say you have 2 users (S1 & S2) and 3 recipients (R1, R2 & R3). You have 1 Twilio-provided number (N1).
S1 sends a message to R1 via your app, you use N1 to send the message via the Twilio API. R1 receives the message from N1. If they reply, you receive a message to N1 from R1 so you know you need to forward it to S1.
S1 sends a message to R2 via your app, R2 has not yet received any messages so you can reuse N1 to send the message. R2 replies to N1 and again you can forward it to S1. If this is delivered in-app, no further problems, if the reply is forwarded via SMS then we'd need to provision a new number (N2) to enable S1 to reply to R2's reply.
S2 sends a message to R3 via your app, as before you can reuse N1 and still route the reply correctly.
Now if S2 sends a message to R1, we realise that R1 has already received messages from S1 using number N1. In this case we can't use N1 because we cannot identify who the reply was intended for. If we haven't already, we need to provision a new number (N2) and now we can send the message so R1. When R1 replies to N2 we know the reply needs to be forwarded to S2.
The more users sending to one recipient, the bigger (and more expensive) your number pool gets. It's probably worth implementing some kind of timeout (say 72 hours) in which the recipient can reply. So in this case if the timeout had expired after S1 sent the message to R1 via N1, we could reuse N1 for the communication between S2 and R1. Obviously this isn't entirely foolproof but it could reduce costs.
Identity
The other issue with sending from a pooled number. I send a message to Dan via an app, and he receives that message from a random number:
Hi Dan, how are you?
How does Dan know who sent the message? You'd have to add some identifier to every message (or at least the first in each conversation thread).

How can I monitor Facsimile/400 and know when it stops sending faxes?

here's my situation:
We are using Facsimile/400 on a IBM System i and sometimes it just stops sending faxes. Everything seems in order but the faxes just pile up with a "Sending" status.
This is an intermittent problem that cannot be provoked manually so I want to come up with a program that checks that the fax is still running.
Here are the problem's symptoms when it happens:
In CHKFAXSTS, all the faxes have the "Sending" status
The QFFSNDFAX output queue is empty
The QFFSNDERR output queue is filled with the currently sending faxes and the previous faxes in error
Now how can I know that the fax is still sending faxes?
I can get the list of the spooled files in QFFSNDERR and check if a spooled file is lingering there too long, but how can I know it's status is "Sending"? - I don't want to catch the faxes that have a wrong fax number etc.
If you are still looking for a solution try asking on the MIDRANGE-L mailing list
Here's the approach I used:
I found the table QUSRSYS/QAFQSND, which contains the complete list of faxes as they can be seen in CHKFAXSTS.
With a SQL query, I can now check if there are faxes on the "Sending" status for too long.

How can I set triggers for sendmail?

If my email id receives an email from a particular sender, can I ask sendmail to trigger a different program and pass on the newly arrived email to it for further processing? This is similar to filters in gmail. Wait for some email to arrive, see if it matches the criteria and take some action if it does.
This is what Procmail is for.
Set Sendmail up to use procmail as the mail delivery agent (MDA), or set up your .forward to pipe stuff through procmail. (See the man page.)
Then you can write your .procmailrc to do all sorts of things along these lines.
This filter predates gmail. Still useful if you're running a mail server.
are you talking about email clients? If so then you can set rules in outlook and I am sure there mustbe ways in other email cleints too!! If u are asking something else. sorry
ok. then I suggest Colins method.. I use cron to monitor emails (for a particluar domain) and send text messages as alerts!. Similar to what you are asking!
We handle this by having a cron process running on the mail server which watches the inbox directory and scans any new messages (files) every 10 minutes or so.
When the process finds an email of interest, it fires the information off to another process which then reacts to the new message (and, in our case, removes the message from the inbox).
--edit--
Finding the email inbox depends on your implementation - check the 'manual' your version of sendmail for details - we direct incoming email to a special directory or have parameters to work out the inbox details. I don't feel it would be useful to be more specific as the answer to 'where is the inbox' is 'it depends'.
As for the pattern to search for - we decode the email message (a text file) into a DOM that we can manipulate. For example, we can then look for specific words in property 'subject'.

Resources