I am trying to recreate the example on the Twilio site: https://www.twilio.com/docs/conversations/group-texting?code-sample=code-send-a-second-conversational-message&code-language=PHP&code-sdk-version=6.x#scenario-1-set-up-a-group-message-with-one-chat-participant-and-two-sms-participants
I have it working to a point of adding a participant and it fails.
My php script consists of:
<?php // Update the path below to your autoload.php, // see https://getcomposer.org/doc/01-basic-usage.md require __DIR__ . '/cron/twilio-php-main/src/Twilio/autoload.php'; use Twilio\Rest\Client; $GLOBALS = require __DIR__ . '/includes/config.php'; $twilio = new Client($GLOBALS['twSID'], $GLOBALS['twToken']); $conversation = $twilio->conversations->v1->conversations ->create([ "friendlyName" => "RawesomePaws" ] ); print("Created conversation.\n"); print_r($conversation . "\n"); print("conversation -> sid = ".$conversation->sid . "\n"); // CH16ac1d4633184feebc3907546cf9ccfc print("About to add Rawesome Phone.\n"); $participant = $twilio->conversations->v1->conversations($conversation->sid) ->participants ->create([ "identity" => "Rawsome Orders", "messagingBindingProjectedAddress" => "+MYTWILIONUMBER" ] ); print("Added RawsomePawsOrders.\n"); print("participant -> id = " . $participant->sid . "\n"); print("About to add robs Phone.\n"); $participant = $twilio->conversations->v1->conversations($conversation->sid) ->participants ->create([ "messagingBindingAddress" => "+MYPERSONALNUMBER" ] ); print("Added Rob.\n"); print($participant->sid); $message = $twilio->conversations->v1->conversations($conversation->sid) ->messages ->create([ "body" => "Hi there. What did you think of the listing I sent?", "author" => "RawesomePaws" ] ); print("Sent Message.\n"); print($message->sid);
I get to the code above
$participant = $twilio->conversations->v1->conversations($conversation->sid) ->participants ->create([ "messagingBindingAddress" => "+MYPERSONALNUMBER" ] );
and it fails:
Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 409] Unable to create record: Group MMS with given participant list already exists as Conversation CHb3a38b8e12f5477c94e05c5ef6946b80 in /home/customer/www/sirota-consulting.com/public_html/PPLG/cron/twilio-php-main/src/Twilio/Version.php:88
All of the phone numbers are correct and I am getting different errors on the same line. Any suggestions or examples? I just want to create a group message so that all people notified can respond and all people in the message can get it...
It looks like you may have a participant bound to a previous covnersation. A participant is uniquely tied to a specific conversation using a unique pairing of their mobile phone number and a Twilio proxy conversation number.
If the participant is already in an existing conversation, then you need to use another Twilio proxy conversation number for this new conversation you want to add them too. This will also create a unique thread on their phone (which only makes sense, since they are separate conversations).
I suggest listing the existing conversations to see which conversation they are already a participant of (using that Twilio Proxy number), and remove them.
I find using the Twilio CLI useful when familiarizing yourself with Twilio Conversations.
list conversations twilio api:conversations:v1:conversations:messages:list --conversation-sid CH44xxx
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.