Remove emails from queue

We desperately need a way to remove certain emails from the queue.

Lack of admin features, in general, (cherry pick, assign, delete/disconnect, batch actions) are causing quite a bit of grief.

We have a customer that has emailed us 800 times in the last few days and it has saturated the queue in the contact centre.

I tried to write an API script in Python using the PATCH method to disconnect all emails from a certain sender /api/v2/conversations/callbacks/{conversationId}. But this appears to be only related to calls. Is it possible? If not the API spec should detail which types it is valid for. I'll post my attempt shortly.

How is our center supposed to manage this torrent of duplicate emails and get to the real customers? They only have limited email admin staff so manually addressing these one by one is not an option.

Here is the relevant code:

# Prepare for GET /api/v2/authorization/roles request
 request_headers = {'Authorization': response_json['token_type'] + ' ' + response_json['access_token']}

 conid = '1234567-5bdb-4a20-a447-qwerty'

 patch = {'state': 'disconnected'}

 # Hit the API
 response = requests.patch(cc.api_base + '/api/v2/conversations/emails/' + conid, headers=request_headers, data=patch)

Response json:

{u'code': u'unsupported media type',
 u'contextId': u'12345-d2a9-41c0-8ac4-1ac003234667',
 u'details': [],
 u'errors': [],
 u'message': u'HTTP 415 Unsupported Media Type',
 u'status': 415}

Failure: 415 - Unsupported Media Type

I could use the javascript equivalent of patch_conversations_email to disconnect emails, in your code you seem to be using the endpoint for callbacks.

The media type in the resource's path identifies which media types it applies to. In the case of the one you referenced, that's for callbacks.

Yes, PATCH /api/v2/conversations/emails/{conversationId} is the correct API resource to use to disconnect an email that isn't yours.

Thanks both. I will try shortly. Sorry for being a bit distressed. I must have copied the wrong endpoint. It was the first one I got to in the list, and in my head I was thinking interactions were agnostic.

No joy changing the API endpoint. Still getting Failure: 415 - Unsupported Media Type with my code above - edited with the correct endpoint.

@Jeroen linked to a reference that uses a different Python module to handle the requests.

Is my logic sound for the patch payload using the Requests module?

The 415 - Unsupported Media Type error is because your request is malformed. I'm guessing you're either not sending the content-type header or are sending an invalid value. You should be sending content-type: application/json.

Also, it looks like you're using Python, but not the SDK. Are you aware that there is an SDK for Python? https://developer.mypurecloud.com/api/rest/client-libraries/python/

Yeah I tried adding the content type header, and got a malformed error. I don't have time to learn the SDK (just now) and am much more familiar with the Requests module.

Let me explore getting the content type header working.

If you can post a correlation ID from the failed request, I can take a look. (the ones above appear to be obfuscated)

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