Dory_Z | 2019-04-16 13:54:06 UTC | #1
I'm getting an error when I try to use the api to send sms. The first one goes out ok, but if I try sending a second one I'm getting: "Active Conversation already in use"
My code creates an outbound message conversation, then send a message to a number. When I try to loop thoughts this code I get this error.
- I've used postconversationdisconnect, which does seem to work, but I have to restart my process for it to pick up the disconnect, after I create a conversation, and send the first sms I will get an error.
- Does this happen because of the way I disconnect? do I need to disconncet participant, and then send wrapup code?
- How can I send multiple sms outgoing from the same agent account oauth token authroization?
Please help I'm stuck on this for a long time, and I'm getting a lot of pressure to complete this task.
tim.smith | 2019-04-16 15:16:40 UTC | #2
Can you provide the correlation ID from the error response?
Dory_Z | 2019-04-16 15:34:29 UTC | #3
contextid?
here is one example of such a response: Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '311', 'Connection': 'keep-alive', 'Date': 'Tue, 16 Apr 2019 15:34:01 GMT', 'ININ-Correlation-Id': '7fe230f5-2d21-4921-a79c-0791cc91ac08', 'inin-ratelimit-count': '2', 'inin-ratelimit-allowed': '300', 'inin-ratelimit-reset': '47', 'Strict-Transport-Security': 'max-age=600; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 aae94205fef749bc8580cf140c626670.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'ECB5vQICXzmrMzDnI_8tJIwsomBWTR-mITidw6A6veRmAdPJT1hA=='}) HTTP response body: {"status":400,"code":"active.conversation","message":"Bad request: An active conversation is already in progress","messageWithParams":"Bad request: {details}","messageParams":{"details":"An active conversation is already in progress"},"contextId":"7fe230f5-2d21-4921-a79c-0791cc91ac08","details":[],"errors":[]}
tim.smith | 2019-04-16 15:53:58 UTC | #4
This is intentional. See the documentation for POST /api/v2/conversations/messages (emphasis added):
If there is an existing conversation between the remote address and the address associated with the queue specified in createOutboundRequest then the result of this request depends on the state of that conversation and the useExistingConversation field of createOutboundRequest. If the existing conversation is in alerting or connected state, then the request will fail. If the existing conversation is disconnected but still within the conversation window then the request will fail unless useExistingConversation is set to true.
Dory_Z | 2019-04-16 16:13:20 UTC | #5
But I close the conversation after each message I send. So how should I terminate the conversation so I can just repetativly send? For now I loop and send messages to 3 number from 1..I'm trying to send 30 numbers.
Dory_Z | 2019-04-16 16:15:07 UTC | #6
My reuse converation is with the True flag..
Dory_Z | 2019-04-16 16:16:54 UTC | #7
How can I clear a conversation from If the existing conversation is in alerting or connected state? Would disconnect work, or do I need to detach participant, then do a wrap up manually?
Dory_Z | 2019-04-16 17:19:12 UTC | #8
In Addition I'm using the use existing flag by setting to True. I even query for list of conversation for the agent, which returns an empty list. But it still fails, sending sms with PureCloud seem nearly impossible at this stage :frowning:
What's going on here? Why is this code failing?
body.queueid = queueid body.toaddress = externalcontact.cellphone if numberoverride is None else numberoverride body.toaddressmessengertype = 'sms' body.useexistingconversation = True body.externalcontactid = externalcontact.id newmessageconversation = conversationapi.postconversationsmessages(body) messageconversationinfo = conversationapi.getconversation(newmessageconversation.id) agent = next((user for user in messageconversationinfo.participants if user.purpose == 'agent'), None) if agent is None: raise ValueError('Conversation {} seem to be missing an agent, unexpected error'.format(newmessageconversation.id)) messagebody = PureCloudPlatformClientV2ApiFactory.getapiwithoutrenew('AdditionalMessage') messagebody.textbody = smstext sentmessage = conversationapi.postconversationsmessagecommunicationmessages( newmessageconversation.id, agent.messages[0].id, messagebody ) logging.info('message sent {}'.format(sentmessage)) conversationapi.postconversationdisconnect(newmessageconversation.id)
tim.smith | 2019-04-16 21:15:46 UTC | #9
I don't have access to your org's data, so I can't see what conversations you created/ended/wrapped at what times. You'll need to take a look at the conversations connected to your user when you get that error and then take appropriate steps to complete the active conversation before making a new one. If you need assistance looking at your data, please open a case with PureCloud Care.
Dory_Z | 2019-04-16 21:28:59 UTC | #10
tim.smith, post:9, topic:5005
PureCloud Care
okay what's PureCloud Care?
I just did what you said, I called: conversationapi.getconversations_messages() And got 0 entries in the respsonse, hence no conversations. how can I get help from someone on this?
tim.smith | 2019-04-16 21:29:45 UTC | #11
https://help.mypurecloud.com/articles/contact-purecloud-care/
system | 2019-05-17 21:29:45 UTC | #12
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5005