ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.89k stars 3.4k forks source link

AWX doesn't send Twilio SMS Notification to multiple destinations #14655

Open mahoutukaisali opened 10 months ago

mahoutukaisali commented 10 months ago

Please confirm the following

Bug Summary

AWX version

all AWX version

Select the relevant components

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

fosterseth commented 10 months ago

@mahoutukaisali is there is a jira associated with this?

dmzoneill commented 7 months ago

Hi,

I've run through the setup on a test notification.

image

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.