Twilio hook to customise incoming message (hook_twilio_message_incoming) is not working in D9 and TwilioController has D9 compatibility issues

Created on 21 November 2023, about 1 year ago
Updated 24 July 2024, 5 months ago

I'm trying to use Twilio's incoming SMS service to track incoming SMS from Twilio but it's giveing me the below error

Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned null.

Steps to reproduce

- Open the SMS webhook url> {your_site}/twilio/sms?{twilio_account_params}
Or
- Implement hook hook_twilio_message_incoming in your custom module and then send a message to your Twilio number and check the error in Twilio webhook logs.

Proposed resolution

After debugging this Module, found that it has many compatibility issues with D9 or D10 versions.
I tried to fix the TwilioController compatibility issue and here is the patch for that but there is another error in the same controller is still unresolved.

Error: Call to undefined function Drupal\twilio\Controller\twilio_command() in Drupal\twilio\Controller\TwilioController->receiveMessage()
I found this function is available in the Twilio module compatible with Drupal 7 but it's been removed from the latest versions. So either we can eliminate this call permanently or we'll have to add its definition as well to fix the above error.

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇮🇳India arti.singh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arti.singh
  • 🇮🇳India arti.singh

    Patch without twilio_command function -

  • Status changed to Needs review about 1 year ago
  • Status changed to RTBC 5 months ago
  • 🇨🇭Switzerland handkerchief

    Hi arti.singh, thank you very much.

    I had the same error:
    Error: Call to undefined function Drupal\twilio\Controller\twilio_command() in Drupal\twilio\Controller\TwilioController->receiveMessage() (Zeile 65 in /modules/contrib/twilio/src/Controller/TwilioController.php).

    Your patch in #2 has fixed the error, the hook is working.

    It would be great if someone could confirm or integrate this.

Production build 0.71.5 2024