Web socket responses how to narrow down

We have code that listens in on ivr calls, we want to detect when the caller hangs up vs our person who hangs up. We however get mixed responses, sometimes two rows of data, sometimes 4 rows of data. What exactly differentiates these? We have been looking at them and the only diff seems to be end call times, and a correlation id. What is that correlation id for? How can we get this to unique rows only, since one call generates about 13 responses?

detect when the caller hangs up vs our person who hangs up

Inspect the disconnectType for each participant to determine who ended the call:

  • client - the disconnect was triggered by UI or public API on this participant (i.e. disconnected self)
  • peer - the disconnect was triggered by another participant in the conversation (i.e. you were the last party in the call)
  • endpoint - the disconnect was triggered by the media endpoint for this participant (i.e. phyiscal phone hung up)
  • system - the disconnect was triggered by the system
  • transfer - the disconnect was the result of a transfer that replaced the participant

We however get mixed responses, sometimes two rows of data, sometimes 4 rows of data. What exactly differentiates these?

I'm not sure what you mean by "rows" of data. Do you mean participants in a conversation? If so, the participantType property indicates what the participant was (agent, customer, ivr, acd, etc.). Different handling of conversations produces different sets of participants.

What is that correlation id for?

It's for troubleshooting purposes.

How can we get this to unique rows only, since one call generates about 13 responses?

Do you mean you receive 13 conversation topic event notifications? A notification is raised any time the conversation changes. Compare the payload of subsequent events to determine what changed in the new event.

Given the code to parse this, we get the following response.

Sometimes we get 2 rows, sometimes 4.

We are trying to detect who hung up the call, it seems not to matter, as when testing either, there appears to be no consistency to the data that comes back.

What conditions can we make to know if the caller hung up, or the answerer hung up?

Thanks for your help on this.

ws.on('message', function incoming(data) {
    
    let tmpData = JSON.parse(data);
    if(tmpData.eventBody && tmpData.eventBody.participants && tmpData.eventBody.participants.length === 4){
    
      let customer = find(tmpData.eventBody.participants,{purpose: 'customer',  state:'connected', direction: 'inbound'});
      let interpreter = find(tmpData.eventBody.participants,{purpose: 'customer', state:'disconnected', direction: 'outbound'});

      if(customer && interpreter){
        console.log('1. customer - ', customer);
        console.log('1. interpreter - ', interpreter);
      }else{

        customer = find(tmpData.eventBody.participants,{purpose: 'customer',  state:'disconnected', direction: 'inbound'});
        interpreter = find(tmpData.eventBody.participants,{purpose: 'customer', state:'connected', direction: 'outbound'});

        if(customer && interpreter){
          console.log('2. customer - ', customer);
          console.log('2. interpreter - ', interpreter);
        }
      }
    }
    
  });

Response data below

  1. customer - { muted: false,
    confined: false,
    recording: false,
    recordingState: 'none',
    id: '1724767e-dbd1-4360-b874-a50d82109895',
    name: 'Atlanta Northeast GA',
    address: 'tel:+1770#######',
    connectedTime: '2018-06-26T20:00:10.328Z',
    purpose: 'customer',
    state: 'connected',
    direction: 'inbound',
    held: false,
    wrapupRequired: false,
    queue: { id: '5cd3adeb-eef0-4b11-818e-33a5b512abc8' },
    attributes: { audioAccessId: '12345' },
    provider: 'Edge' }
  2. interpreter - { muted: false,
    confined: false,
    recording: false,
    recordingState: 'none',
    id: '628d48d3-4cd0-4c9b-b43f-a3984ab88853',
    name: 'Atlanta Northeast GA',
    address: 'tel:+1770#######',
    connectedTime: '2018-06-26T20:00:35.353Z',
    endTime: '2018-06-26T20:00:39.782Z',
    purpose: 'customer',
    state: 'disconnected',
    direction: 'outbound',
    disconnectType: 'endpoint',
    held: false,
    wrapupRequired: false,
    attributes: {},
    provider: 'Edge',
    peer: 'fd7bd0c5-0508-4bda-ad95-d281409e0415' }
  3. customer - { muted: false,
    confined: false,
    recording: false,
    recordingState: 'none',
    id: '1724767e-dbd1-4360-b874-a50d82109895',
    name: 'Atlanta Northeast GA',
    address: 'tel:+1770#######',
    connectedTime: '2018-06-26T20:00:10.328Z',
    purpose: 'customer',
    state: 'connected',
    direction: 'inbound',
    held: false,
    wrapupRequired: false,
    queue: { id: '5cd3adeb-eef0-4b11-818e-33a5b512abc8' },
    attributes: { audioAccessId: '12345' },
    provider: 'Edge' }
  4. interpreter - { muted: false,
    confined: false,
    recording: false,
    recordingState: 'none',
    id: '628d48d3-4cd0-4c9b-b43f-a3984ab88853',
    name: 'Atlanta Northeast GA',
    address: 'tel:+1770#######',
    connectedTime: '2018-06-26T20:00:35.353Z',
    endTime: '2018-06-26T20:00:39.782Z',
    purpose: 'customer',
    state: 'disconnected',
    direction: 'outbound',
    disconnectType: 'endpoint',
    held: false,
    wrapupRequired: false,
    attributes: {},
    provider: 'Edge',
    peer: 'fd7bd0c5-0508-4bda-ad95-d281409e0415' }

See my post above about disconnectType.

Thanks Tim, I did get this figured out off what you wrote.

Tim,

Why on first initial call we often get a 400 when making a socket connection to a channel with 2 topics?

It seems random, we have not been able to reproduce yet, but it continues to happen.

Thx

I'll need the correlation ID and response body to be able to look into it.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.