Cannot answer call via api

I'm trying to automate the call actions (Make call, answer, hang up, transfer, etc) via api, to be able to integrate those actions into our testing project.
I launch the WebRTC phones on the browsers and grab the access token for both users (agent1 is the caller and agent2 is the receiver)
I am able to successfully make a call from agent1 to agent2 via api, but answering the call via api isn't working.

Here's what the "answer call" http request looks like:
URI: https://api.mypurecloud.com/api/v2/conversations/calls/{call id}/participants/{participant id}
HTTP method: PATCH

Headers:
Authorization: "Bearer {receiver access token}"
Host: api.mypurecloud.com
Content-Type: application/json

Body:
{
"state": "connected"
}

Response status: 202 Accepted
Although I get response 202, nothing happens and the call continues to ring.

Browser: Chrome
Sending the api calls via postman.

I appreciate any help to make this work.

Make sure you're logged in to your station correctly and have allowed apps to place calls. If you've done that, open a case with Genesys Cloud Care to investigate. The API response is returning successfully, but something downstream is failing that we are unable to investigate via the forum.

Hello,

Hello,

You can also have a look at the following blog - Clarifying call control support to answer a call or to make a call using Platform API .
It covers different type of phones and setup - you should find some explanations in it (depending on your phone type/setup).

Regards,

Hi Tim,
Yes, that option is enabled, that's why I can successfully start the call via api. Ok, I will create a case to investigate further. Thank you

Hi Jerome,
Yes, I actually had already looked at that page before and it seems that my configuration is in accordance with the requirements.
Thank you

If you are using Genesys Cloud Web client with the embedded WebRTC phone, what matters when it comes to answering a call via API is around persistent connection.
Persistent connection must be configured/enabled (for the phone that needs to answer the call via API). And there must be an active persistent connection so that the request to answer call via API will be taken into account (i.e. a call must have been established with that phone "recently" - I mean not longer than max persistent connection time that was configured).

Thank you for the information Jerome. I will consider that as well.

I'm finding something very confusing while trying to grab the call id and participant id, to send the api request to answer the call:

Above is my agent1 on the browser. The user id is 0814e7bc-346d-4e26-a1cc-d7ea60f07a7e, as you can see in the url. However, when I make the request to get the active conversations, this is what I get:

{
    "entities": [
        {
            "id": "57af9819-3b8d-4cf5-974b-da91e9b16bb2",
            "startTime": "2024-05-24T19:41:11.358Z",
            "address": "sip:1182@10.42.94.5;user=phone",
            "participants": [
                {
                    "id": "d8d3bc0f-33eb-4cda-ab54-b71db6711f95",
                    "startTime": "2024-05-24T19:41:11.358Z",
                    "userUri": "/api/v2/users/892eab2f-a047-4b74-a671-d3a5f7e4ce21",
                    "userId": "892eab2f-a047-4b74-a671-d3a5f7e4ce21",
                    "purpose": "user",
                    "participantType": "Internal",
                    "address": "sip:604230d31e9e5e1b7bb923dc+ingeniusdemo.orgspan.com@localhost",
                    "ani": "sip:604230d31e9e5e1b7bb923dc+ingeniusdemo.orgspan.com@localhost",
                    "dnis": "tel:1181",
                    "wrapupRequired": false,
                    "mediaRoles": [
                        "full"
                    ],
                    "attributes": {},
                    "calls": [
                        {
                            "state": "dialing",
                            "initialState": "contacting",
                            "id": "37ecbab1-fb61-4b67-8b18-374e55d70ee2",
                            "direction": "outbound",
                            "recording": false,
                            "recordingState": "none",
                            "muted": false,
                            "confined": false,
                            "held": false,
                            "securePause": false,
                            "segments": [],
                            "disconnectReasons": [],
                            "provider": "Edge",
                            "self": {
                                "nameRaw": "",
                                "addressNormalized": "sip:604230d31e9e5e1b7bb923dc+ingeniusdemo.orgspan.com@localhost",
                                "addressRaw": "604230d31e9e5e1b7bb923dc+ingeniusdemo.orgspan.com",
                                "addressDisplayable": "unavailable"
                            },
                            "other": {
                                "name": "Extension",
                                "nameRaw": "",
                                "addressNormalized": "tel:1181",
                                "addressRaw": "tel:1181",
                                "addressDisplayable": "unavailable"
                            },
                            "afterCallWork": {},
                            "afterCallWorkRequired": false
                        }
                    ]
                },
                {
                    "id": "0dd5da9d-61eb-448e-93d8-ae1ae91b80fd",
                    "startTime": "2024-05-24T19:41:11.379Z",
                    "userUri": "/api/v2/users/0814e7bc-346d-4e26-a1cc-d7ea60f07a7e",
                    "userId": "0814e7bc-346d-4e26-a1cc-d7ea60f07a7e",
                    "purpose": "user",
                    "participantType": "Internal",
                    "address": "sip:604230d33efa371b7a5f6b65+ingeniusdemo.orgspan.com;tgrp=efc71906-5ac5-49aa-aa5e-dd4f66dac951;trunk-context=ingeniusdemo@localhost",
                    "ani": "sip:1182@10.42.94.5;user=phone",
                    "aniName": "AD3agent2",
                    "dnis": "sip:604230d33efa371b7a5f6b65+ingeniusdemo.orgspan.com;tgrp=efc71906-5ac5-49aa-aa5e-dd4f66dac951;trunk-context=ingeniusdemo@localhost",
                    "wrapupRequired": false,
                    "mediaRoles": [
                        "full"
                    ],
                    "attributes": {},
                    "calls": [
                        {
                            "state": "alerting",
                            "initialState": "alerting",
                            "id": "169b2e95-8d93-4563-8551-bbc1f4402e55",
                            "direction": "inbound",
                            "recording": false,
                            "recordingState": "none",
                            "muted": false,
                            "confined": false,
                            "held": false,
                            "securePause": false,
                            "segments": [],
                            "startAlertingTime": "2024-05-24T19:41:11.571Z",
                            "disconnectReasons": [],
                            "provider": "Edge",
                            "peerId": "37ecbab1-fb61-4b67-8b18-374e55d70ee2",
                            "self": {
                                "nameRaw": "Extension",
                                "addressNormalized": "sip:604230d33efa371b7a5f6b65+ingeniusdemo.orgspan.com;tgrp=efc71906-5ac5-49aa-aa5e-dd4f66dac951;trunk-context=ingeniusdemo@localhost",
                                "addressRaw": "sip:604230d33efa371b7a5f6b65+ingeniusdemo.orgspan.com@10.42.94.5;language=en-US;user=station",
                                "addressDisplayable": "unavailable"
                            },
                            "other": {
                                "name": "AD3agent2",
                                "nameRaw": "AD3agent2",
                                "addressNormalized": "sip:1182@10.42.94.5;user=phone",
                                "addressRaw": "sip:1182@10.42.94.5;user=phone",
                                "addressDisplayable": "unavailable"
                            },
                            "afterCallWork": {},
                            "afterCallWorkRequired": false
                        }
                    ]
                }
            ],
            "recordingState": "NONE",
            "divisions": [
                {
                    "division": {
                        "id": "9eb1b27e-acea-4d53-992c-02b789917545",
                        "selfUri": "/api/v2/authorization/divisions/9eb1b27e-acea-4d53-992c-02b789917545"
                    },
                    "entities": [
                        {
                            "id": "892eab2f-a047-4b74-a671-d3a5f7e4ce21",
                            "selfUri": "/api/v2/users/892eab2f-a047-4b74-a671-d3a5f7e4ce21"
                        },
                        {
                            "id": "0814e7bc-346d-4e26-a1cc-d7ea60f07a7e",
                            "selfUri": "/api/v2/users/0814e7bc-346d-4e26-a1cc-d7ea60f07a7e"
                        }
                    ]
                }
            ],
            "recentTransfers": [],
            "securePause": false,
            "utilizationLabelId": "631f0939-be32-495a-baf9-970abb039192",
            "selfUri": "/api/v2/conversations/57af9819-3b8d-4cf5-974b-da91e9b16bb2"
        }
    ],
    "pageSize": 1,
    "pageNumber": 1,
    "total": 1,
    "lastUri": "/api/v2/conversations?pageSize=1&pageNumber=1",
    "firstUri": "/api/v2/conversations?pageSize=1&pageNumber=1",
    "selfUri": "/api/v2/conversations?pageSize=1&pageNumber=1",
    "pageCount": 1
}

If you look at this json object, the agent 1's user id is related to the second participant, which is actually my agent 2! So their id's seem to be swapped around... Either I don't understand this, or there is something wrong going on...

Thank you

What makes you believe the IDs are wrong? Is it this where it's showing Agent 2's name where the user id is Agent 1?

If so, this seems likely correct. The ANI refers to the caller, and it appears this is a from Agent 2 to Agent 1, so the ANI would refer to Agent 2.

If you pull up the conversation in the interaction detail view, it may help provide context for the conversation media data.

Oh, so that is referring to the remote party... Thank you for the clarification.
Let me see if I can make this work now.

I am happy to say that I'm now able to answer the calls via API. I can also successfully perform various other call actions, such as transfer, hold, conference, hang up, etc.
I'm just uneasy about the answer action only working (via API) if a persistent connection has been established first, between the two phones. I'm wondering what would be the best option to "establish" that persistent connection in the first place. Is there a way to do it programatically, other than answering the call on the UI (WebRTC phone)?

Would it make any difference using the SDK? (I wouldn't think so...)

This feature is not currently available. I would strongly recommend that you vote for and comment on the idea requesting an API be made available for this. My understanding is that this feature is not intended to be part of the platform, so it will only work if you're using the OOTB UI. You'll need to make your voice heard that this should be part of the platform. https://genesyscloud.ideas.aha.io/ideas/TEL-I-446.

Edit for clarification: the statement about an API endpoint not being available for this was meant to convey that it's not an API-driven feature, not that there's an API endpoint that isn't being released. The functionality in the linked idea is being implemented as an inherent feature and not something you have to do via the API.

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