AWX doesn't send Twilio SMS Notification to multiple destinations
Please confirm the following
- [X] I agree to follow this project's code of conduct.
- [X] I have checked the current issues for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am NOT reporting a (potential) security vulnerability. (These should be emailed to
[email protected]instead.)
Bug Summary
- Twilio Notification only sends an SMS notification to a first-line of phone numbers list of Destination SMS Number(s) configuration, it ignores other phone numbers written from the second lines.
- Twilio website mentions that their API is able to send list of numbers:
- https://support.twilio.com/hc/en-us/articles/223181548-Can-I-set-up-one-API-call-to-send-messages-to-a-list-of-people-
- AAP website mentions that we can set the phone numbers list in as a destination.
- https://docs.ansible.com/automation-controller/latest/html/userguide/notifications.html#twilio
AWX version
all AWX version
Select the relevant components
- [ ] UI
- [ ] UI (tech preview)
- [X] API
- [ ] Docs
- [ ] Collection
- [ ] CLI
- [ ] Other
Installation method
kubernetes
Modifications
no
Ansible version
No response
Operating system
No response
Web browser
No response
Steps to reproduce
Configure Destination SMS Number(s) in Twilio Notification with multiple phone numbers and run a Test.
+818012345678
+819012345678
Expected results
Twilio Notification sends SMS notifications to all phone numbers written in Destination SMS Number(s).
Actual results
Twilio Notification only sends an SMS notification to a first line phone number written in Destination SMS Number(s).
Additional information
No response
@mahoutukaisali is there is a jira associated with this?
Hi,
I've run through the setup on a test notification.
I added a few unnecessary debug lines into the loop:
for m in messages:
logger.error(m.body)
logger.error(m.from_email)
logger.error(m.to)
logger.error(m.subject)
failed = False
for dest in m.to:
try:
logger.debug(smart_str(_("FROM: {} / TO: {}").format(m.from_email, dest)))
connection.messages.create(to=dest, from_=m.from_email, body=m.subject)
sent_messages += 1
except Exception as e:
logger.error(smart_str(_("Exception sending messages: {}").format(e)))
failed = True
noting the log output, of a single message with 2 recipients
tools_awx_1 | 2024-01-29 15:52:16,406 ERROR [bb222026] awx.main.notifications.twilio_backend {'body': 'Test Notification 1 https://towerhost'}
tools_awx_1 | 2024-01-29 15:52:16,406 ERROR [bb222026] awx.main.notifications.twilio_backend +447360540134
tools_awx_1 | 2024-01-29 15:52:16,406 ERROR [bb222026] awx.main.notifications.twilio_backend ['+353.........87', '+353.........62']
tools_awx_1 | 2024-01-29 15:52:16,406 ERROR [bb222026] awx.main.notifications.twilio_backend Notification Test 1 https://towerhost
I successfully received the SMS message on both phone numbers. I would kindly have to refer you back to Twilio, check their logs and error messages. There are a number of cases where the message will be ignored, such as trying to send a message to yourself.
You only need 3 lines of code to test this yourself.
from twilio.rest import Client
connection = Client("sid", "token")
connection.messages.create(to="+3538......", from_="+3538.......", body="test")
Or multiple recipients
from twilio.rest import Client
connection = Client("sid", "token")
connection.messages.create(to=['+3538......', '+353......62'], from_="+3538.......", body="test")
If you can give us more information, maybe we can proceed further, but cannot currently reproduce this problem.