I am here to ask you about Twilio functionality. Now I am developing Conference Service using Twilio Service, but faced a difficult problem. When I use connect API, the callback returns a JSON object that includes participant.identity. I want to send participant.name with participant.identity.
This is connect function.
createLocalTracks(options)
.then(localTracks => {
return connect(room.accessToken, {
name: room.roomName,
tracks: localTracks,
})
}).then(room => {
console.log(room.data); // Returns JSON Object that includes only participant_identity.
this.participants.push("You");
})
And console result is like the following.
{
dominantSpeaker: null
isRecording: true
localParticipant: {
...,
identity: 'xxx',
...
}
mediaRegion: "us1"
name: "Soundblock.Project.2608117C-F92E-442A-A67D-4ED428522CE0"
participants: []
sid: "RM6336d72cb198fa58aa37f66af9eaf02d"
state: "connected"
}
I want to get participant_name with identity. So the result must be like the following.
{
dominantSpeaker: null
isRecording: true
localParticipant: {
...,
identity: 'xxx',
participant_name: 'ABC'
...
}
mediaRegion: "us1"
name: "Soundblock.Project.2608117C-F92E-442A-A67D-4ED428522CE0"
participants: [
{ identity: 'YYY', participant_name: 'BCD' },
{ identity: 'ZZZ', participant_name: 'CDE' },
...
]
sid: "RM6336d72cb198fa58aa37f66af9eaf02d"
state: "connected"
}
Is there anyone who can help me with this issue? Thank you.
You have 2 ways to get that:
If you are calling the Twilio API in the back and then creating the object which is served to the front, change it appropriately in the back so that it returns exactly what you need on the front end.
if you are calling directly the Twilio API from the front (or you don't want to change in the back), you can do a interface and mapping appropriately with a class. Something like this:
Manage in your call to the API: