SMS - Twilio - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: SMS - Twilio (/showthread.php?tid=4168) |
SMS - Twilio - Fahd - 02.08.2022 Hi, I'm using to script below to send an SMS via Twilio, What should I change if I have more than one number to send to? value = event.getvalue() if value == true then from_nr = '+13253264263' to_nr = 'Number1' id_nr = '***' -- token_nr = '***' - sms(id_nr, token_nr, from_nr, to_nr, 'Alarm HCWC 009 changed to Alarm OFF') RE: SMS - Twilio - admin - 02.08.2022 You have to make a separate request for each recipient: Code: from_nr = '+13253264263' RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 07:47)admin Wrote: You have to make a separate request for each recipient: Hi, Thanks for the reply, It sends only for the first number RE: SMS - Twilio - admin - 02.08.2022 log what the sms function returns: Code: from_nr = '+13253264263' RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 08:41)admin Wrote: log what the sms function returns: RE: SMS - Twilio - admin - 02.08.2022 If you are using a trial account then you can only send test messages to your own phone number. To send messages to other phone numbers you need a paid account. RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 09:57)admin Wrote: If you are using a trial account then you can only send test messages to your own phone number. To send messages to other phone numbers you need a paid account. Yes I know and I didn't update yet, so numbers 1,2,3 are the same number and the script sends only one SMS instead of 3 RE: SMS - Twilio - admin - 02.08.2022 As I've said - check what you get in logs. Do you get 3 log entries for each script call? RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 10:37)admin Wrote: As I've said - check what you get in logs. Do you get 3 log entries for each script call? My mistake I thought that I wrote the log in the last reply This is the log Code: * arg: 1 As I told you the 3 numbers are the same (till now I will change it the I update the account), I can send the message 3 times if copy and past the code in below 3 times with the same number but it didn't work with the loop for from_nr = '+13253264263' -- put sender SIM nr here to_nr = '' -- put recepient SIM nr here id_nr = '' -- put your ID here token_nr = '' -- put your token here sms(id_nr, token_nr, from_nr, to_nr, 'Alarm HCWC 009 changed to Alarm OFF') RE: SMS - Twilio - admin - 02.08.2022 Post your whole script with the for loop. There's should not be any difference between the loop and copy/pasted multiple sms function calls. RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 11:38)admin Wrote: Post your whole script with the for loop. There's should not be any difference between the loop and copy/pasted multiple sms function calls. Code: value = event.getvalue() RE: SMS - Twilio - admin - 02.08.2022 This might happen because you are sending a message with the same text. Twilio accepts the message but then fails with "Unknown error"/undelivered. If you log the Twilio response you can check the message status in your browser by accessing https://api.twilio.com/2010-04-01/Accounts/ACCOUNT_ID/Messages/MESSAGE_ID.json ("uri" part of the returned JSON by Twilio). Use your id/token as username/password. Your script can be optimized like this: Code: value = event.getvalue() RE: SMS - Twilio - Fahd - 02.08.2022 (02.08.2022, 12:05)admin Wrote: This might happen because you are sending a message with the same text. Twilio accepts the message but then fails with "Unknown error"/undelivered. If you log the Twilio response you can check the message status in your browser by accessing https://api.twilio.com/2010-04-01/Accounts/ACCOUNT_ID/Messages/MESSAGE_ID.json ("uri" part of the returned JSON by Twilio). Use your id/token as username/password.Thank you so much |