fransiska.hendra | 2022-12-14 07:35:17 UTC | #1
Hi,
Just wondering if anyone can help me, I am trying to retrieve webmessaging transcript through API.
So in Conversation Page, we can see a lot of conversation from the customer
But when i tried to retrieved "customer" transcript, from API,
/api/v2/conversations/messages/{conversationId}
I only can retrieve 1 messageID, which doesnt seems right.
Just wondering is there any other API we can call to retrieve webmessaging transcript ?
Any advise, are appreciated.
Thanks Fransiska
Angelo_Cicchitto | 2022-12-14 07:59:42 UTC | #2
Hi @fransiska.hendra we had couple of past posts on this topic, see here: https://developer.genesys.cloud/forum/t/fetching-web-messages-via-the-api/14603/2 https://developer.genesys.cloud/forum/t/api-to-get-historical-message-data/14278/5
fransiska.hendra | 2022-12-14 21:18:34 UTC | #3
thanks @Angelo_Cicchitto ,
I am using recording API now, looks like i get can get the customer transcripts (which is missing if i use messaging API).
Will let you know how it goes. Fransiska
Rolph_Lieverse | 2022-12-19 12:57:00 UTC | #4
Hi Fransiska, very curious on how far you got with this. When using this api : /api/v2/conversations/{conversationId}/recordings You get a lot of data which you might want to trim in only 'exporting' the "messageText". Thxs. Rolph
fransiska.hendra | 2022-12-19 23:56:20 UTC | #5
hi Rolph,
I can get full transcripts using the API, i only need purpose (customer , agent or botflow), timestamp, transcript. Here is my code below (its Apex Salesforce).
HttpResponse response = purecloud.SDK.Rest.get('/api/v2/conversations/'+conversationId+'/recordings');
if(response.getStatus()=='OK')
{
String resBody = response.getBody();
recordings = (List<Object>) JSON.deserializeUntyped(resBody);
if (recordings!=null && !recordings.isEmpty()) {
for (Object recording : recordings) {
String s = JSON.serialize(recording);
Map<String,Object> msg= (Map<String,Object>) JSON.deserializeUntyped(s);
List<Object> transcripts= (List<Object>) msg.get('messagingTranscript');
if(transcripts!=null && !transcripts.isEmpty()){
for(Object transcript : transcripts){
String st = JSON.serialize(transcript);
Map<String,Object> stObj= (Map<String,Object>) JSON.deserializeUntyped(st);
Object fromExternalContact = (Object) stObj.get('fromExternalContact');
Object fromUser = (Object) stObj.get('fromUser');
String participant_id;
String timestamp;
String purp;
DateTime messageTime;
String messageId;
String msgText;
//this is Customer
if(fromExternalContact!=null){
String normStr = JSON.serialize(fromExternalContact);
Map<String,Object> normObj =(Map<String,Object>) JSON.deserializeUntyped(normStr);
participant_id=(String)normObj.get('id');
timestamp=(String)stObj.get('timestamp');
purp='customer';
messageTime =timestamp !='' ? convertTimestamp(timestamp): null;
messageId=(String)stObj.get('id');
msgText=(String)stObj.get('messageText');
}
//this is Agent
else if(fromUser!=null){
String normStr = JSON.serialize(fromUser);
Map<String,Object> normObj =(Map<String,Object>) JSON.deserializeUntyped(normStr);
participant_id=(String)normObj.get('id');
timestamp=(String)stObj.get('timestamp');
purp='agent';
messageTime =timestamp !='' ? convertTimestamp(timestamp): null;
messageId=(String)stObj.get('id');
msgText=(String)stObj.get('messageText');
}
//this is BOT - workflow
else{
participant_id='-';
timestamp=(String)stObj.get('timestamp');
purp='workflow';
messageTime =timestamp !='' ? convertTimestamp(timestamp): null;
messageId=(String)stObj.get('id');
msgText=(String)stObj.get('messageText');
}
system | 2023-01-18 23:56:51 UTC | #6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 17635