I'm trying to set up a few API calls to Twilio's Conversations Service so I can connect CRM data in Google Sheets to Twilio's Frontline App. I'm struggling to successfully modify a participant.
I try to call Twilio's Edit Conversation Participant API using the code below.
function editParticipantAttributes() {
var twUrl = 'https://conversations.twilio.com/v1/Conversations/' + chSid + '/Participants/' + mbSid;
var options = {
method: 'post',
headers: {
'Authorization': twAuthHeader,
},
followRedirects: true,
muteHttpExceptions: true,
payload: {attributes: JSON.stringify({
customer_id: '1',
display_name: 'First Last'
})
}
}
var response = UrlFetchApp.fetch(twUrl, options);
Logger.log(response)
}
The Twilio Conversations Resource uses the following cURL as an example:
curl -X POST "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "DateUpdated=2019-05-15T13:37:35Z" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Here's the info on the attributes parameter:
An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
I get a response back with information about the appropriate participant, but attributes remains "{}". Can anyone please help me see my mistake?
Response:
{"last_read_message_index": null, "date_updated": "2023-05-25T00:45:09Z", "last_read_timestamp": null, "conversation_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "url": "https://conversations.twilio.com/v1/Conversations/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Participants/MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "date_created": "2023-05-24T23:05:37Z", "role_sid": "RLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "sid": "MBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "attributes": "{}", "identity": null, "messaging_binding": {"proxy_address": "+1XXXXXXXXXX", "type": "sms", "address": "+1XXXXXXXXXX"}}
Thanks in advance!