Skip to content
Advertisement

Twilio Conversation Fatal error when trying to send message?

I am trying to do a group conversation following the twilio samples online. I have the conversation and the people are connected (I think) but when I go send a message I get the following error:

Fatal error: Uncaught TwilioExceptionsRestException: [HTTP 412] Unable to create record: Group MMS activation failed in

Does anyone have any working samples of a working conversation in PHP? If you want I can post my full code (minus the keys and phone numbers)

UPDATE:

Code to set up conversation:

$conversation = $twilio->conversations->v1->conversations
                                          ->create([
                                                       "friendlyName" => "RawesomePaws"
                                                   ]
                                          );

I then added the Twilio phone and 3 other SMS phone #’s

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc23XXXX")
                                         ->participants
                                         ->create([
                                                      "identity" => "Rawesome Orders",
                                                      "messagingBindingProjectedAddress" => "+1408840XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1408409XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1815210XXXX"
                                                  ]
                                         );

$participant = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                         ->participants
                                         ->create([
                                                      "messagingBindingAddress" => "+1408540XXXX"
                                                  ]
                                         );


Now that the conversation is set up, I try to send a group message:

$message = $twilio->conversations->v1->conversations("CHb61ad48141884350896047adc237XXXX")
                                     ->messages
                                     ->create([
                                                  "body" => 'Message Body',
                                                  "author" => 'Rawesome Orders',
                                             ]
                                     );

and here is the output when I am in the terminal:

Fatal error: Uncaught TwilioExceptionsRestException: [HTTP 412] Unable to create record: Group MMS activation failed in /home/customer/www/sirota-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
Stack trace:
#0 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php(223): TwilioVersion->exception(Object(TwilioHttpResponse), 'Unable to creat...')
#1 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Rest/Conversations/V1/Conversation/MessageList.php(57): TwilioVersion->create('POST', '/Conversations/...', Array, Array, Array)
#2 /home/customer/www/XXX-consulting.com/public_html/PPLG/sms_SendMessage.php(15): TwilioRestConversationsV1ConversationMessageList->create(Object(TwilioValues))
#3 {main}
  thrown in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php on line 88

Update 2 This is the complete log from phpLog

[24-Apr-2021 01:11:59 UTC] -- BEGIN Twilio API Request --
[24-Apr-2021 01:11:59 UTC] Request Method: POST
[24-Apr-2021 01:11:59 UTC] Request URL: /v1/Conversations/CHb61ad48141884350896047adc237cf45/Messages
[24-Apr-2021 01:11:59 UTC] Request Headers: 
[24-Apr-2021 01:11:59 UTC] User-Agent: twilio-php/6.16.0 (PHP 7.3.27)
[24-Apr-2021 01:11:59 UTC] Accept-Charset: utf-8
[24-Apr-2021 01:11:59 UTC] Content-Type: application/x-www-form-urlencoded
[24-Apr-2021 01:11:59 UTC] Accept: application/json
[24-Apr-2021 01:11:59 UTC] -- END Twilio API Request --
[24-Apr-2021 01:12:00 UTC] Status Code: 412
[24-Apr-2021 01:12:00 UTC] Response Headers:
[24-Apr-2021 01:12:00 UTC] Date:  Sat, 24 Apr 2021 01:12:00 GMT
[24-Apr-2021 01:12:00 UTC] Content-Type:  application/json; charset=utf-8
[24-Apr-2021 01:12:00 UTC] Content-Length:  129
[24-Apr-2021 01:12:00 UTC] Connection:  keep-alive
[24-Apr-2021 01:12:00 UTC] Twilio-Request-Id:  RQbd66fd8e4b548596a430a2646a4376f2
[24-Apr-2021 01:12:00 UTC] Twilio-Request-Duration:  0.195
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Origin:  *
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Headers:  Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Methods:  GET, POST, DELETE, OPTIONS
[24-Apr-2021 01:12:00 UTC] Access-Control-Expose-Headers:  ETag
[24-Apr-2021 01:12:00 UTC] Access-Control-Allow-Credentials:  true
[24-Apr-2021 01:12:00 UTC] X-Powered-By:  AT-5000
[24-Apr-2021 01:12:00 UTC] X-Shenanigans:  none
[24-Apr-2021 01:12:00 UTC] X-Home-Region:  us1
[24-Apr-2021 01:12:00 UTC] X-API-Domain:  conversations.twilio.com
[24-Apr-2021 01:12:00 UTC] Strict-Transport-Security:  max-age=31536000
[24-Apr-2021 01:12:00 UTC] PHP Fatal error:  Uncaught TwilioExceptionsRestException: [HTTP 412] Unable to create record: Group MMS activation failed in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
Stack trace:
#0 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php(223): TwilioVersion->exception(Object(TwilioHttpResponse), 'Unable to creat...')
#1 /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Rest/Conversations/V1/Conversation/MessageList.php(57): TwilioVersion->create('POST', '/Conversations/...', Array, Array, Array)
#2 /home/customer/www/XXX-consulting.com/public_html/PPLG/sms_SendMessage.php(15): TwilioRestConversationsV1ConversationMessageList->create(Object(TwilioValues))
#3 {main}
  thrown in /home/customer/www/XXX-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php on line 88

Advertisement

Answer

Twilio developer evangelist here.

I think the error codes for this are yet to be published, which I will follow up on internally. I have found some documentation for this error though.

Typical reasons for failure include:

  • Less than 3 non-chat participants in the conversation
  • There’s a chat participant in the conversation
  • There’s an existing group conversation with the exact same participants
  • There’s a participant with a ProjectedAddress only

Note that a participant with an Identity and a ProjectedAddress counts as a non-chat participant.

As far as I can see from your code, you have 4 non-chat participants (notably, the limit for group MMS is 4 participants right now), so that is fine. You have one participant with a ProjectedAddress and an Identity, which is fine. There are no participants with only a ProjectedAddress.

That leaves one potential issue, that there is already an existing group with these exact participants.

In order to check what’s going on, I would now do a couple of things.

First, double check that these participants were correctly created and none are missing a property, particularly the participant with the Identity and ProjectedAddress.

Then, check to see if you have an existing conversation object that also has these participants.

If neither of those checks comes up with anything, let me know and I’ll escalate the ticket you have open.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement