Facing issue while adding the non chat participants using the JS SDK in twilio conversation
I have done following things to add the non chat participants in the JS SDK
Twilio.Conversations.Client.create(token).then(client => {
console.log(client);
client.on("stateChanged", (state) => {
if (state === "failed") {
console.log("fail");
// The client failed to initialize
return;
}
if (state === "initialized") {
console.log("init");
// Use the client
}
});
client.createConversation().then(async function(conversation) {
console.log(conversation, 'conversation');
await conversation.join();
const proxyAddress = "twilio number";
const address = "phone Number";
const attributes = {
identity: address
};
const messeges = await conversation.getMessages();
console.log(messeges, 'messeges')
conversation.addNonChatParticipant(proxyAddress, address, attributes).then(function(a) {
console.log(a, 'a');
}).catch(function(err) {
console.log(err, 'while adding the Participant');
});
}).catch(function(err) {
console.log(err, 'con');
});
});
It gives me following and its not that much explained anywhere. moreover I got the client object and the conversation object as well but after that I can't add Participant
Error: Conflict at e.<anonymous> (twilio-conversations.min.js:129:209472)at Qc (twilio-conversations.min.js:129:30955)at Generator._invoke (twilio-conversations.min.js:129:30737)at forEach.e.<computed> [as next] (twilio-conversations.min.js:129:31399)at t (twilio-conversations.min.js:129:117709)at o (twilio-conversations.min.js:129:117920) 'while adding the Participant'
This Conflict error appears when you attempt to add a participant to a new conversation, but this participant is already in an active conversation with the same proxy_address (Twilio phone number).
In other words, you can’t have more than one active conversation using the same To/From pair. More info here: https://www.twilio.com/docs/conversations/inbound-autocreation#key-principle-the-tofrom-number-pair
To solve this issue, you have 2 options:
If you have issues finding the conversation SID where your participant is, you could use Participant Conversation Resource, that allows you to find the conversations that a phone number has had https://www.twilio.com/docs/conversations/api/participant-conversation-resource