Guy_Brown | 2023-08-23 20:04:24 UTC | #1
I am working with /api/v2/routing/queues/. I am able to run the data action and receive the response. However I am looking for the assigned call script and it is returning defaultScripts.CALL.id. When I try to use this in the output contract it does not work. I need the script id to assign it to the queue. How can I pull this particular value out of the response?
Charaf | 2023-08-24 09:18:51 UTC | #2
Hi @Guy_Brown,
To extract all the script Ids from the API response, here's how you can achieve it:
- Create a data action that makes a GET request to the following endpoint:
GET /api/v2/routing/queues
- Define an output of type Array (for example, named 'ids').
- In your response template, use the following:
{
"translationMap": {
"ids": "$.entities[*].defaultScripts.CALL.id"
},
"translationMapDefaults": {
"ids": "[]"
},
"successTemplate": "{\"ids\": ${ids}}"
}
The result is an array containing the script Ids:
If you want to get only the script Id for a specific queue, you can modify the GET request to include a queue name filter:
GET /api/v2/routing/queues?name="QUEUE_NAME"
In this case, the result will include a single Id:
I hope that helps.
Best regards,
Charaf
Guy_Brown | 2023-08-24 18:27:30 UTC | #3
Thank you for the response. I am refining the request down to a single queue with an input variable. /api/v2/routing/queues/$input.queueid which works great. I created your array and am using the translation map provided.(Thank you very much,) but it is not returning the results . In the result I do see the response without the solution "defaultScripts.CALL.id": "b2bac8xx"
Charaf | 2023-08-24 20:10:25 UTC | #4
@Guy_Brown, since you are using the following API endpoint:
GET /api/v2/routing/queues/{queueId}
All you need to do is define an output variable as a string:
Now, the response template should appear as follows:
{
"translationMap": {
"id": "$.defaultScripts.CALL.id"
},
"translationMapDefaults": {
"id": "\"\""
},
"successTemplate": "{\"id\": ${id}}"
}
The response will return the script Id associated to the input queue.
Let me know if that resolves your issue :slight_smile:
Best regards,
Charaf
Guy_Brown | 2023-08-25 15:31:20 UTC | #5
I am still not seeing the response, Here is what I have configured.
/api/v2/conversations/callbacks header { "scriptId": "$input.scriptid", "queueId": "", "routingData": { "queueId": "${input.queueId}", "languageId": "", "priority": 0, "skillIds": ["$input.skillid"], "preferredAgentIds": [], "scoredAgents": [ { "agent": { "id": "", "name": "", "selfUri": "" }, "score": 0 } ], "routingFlags": [] }, "callbackUserName": "$input.remotename", "callbackNumbers": ["${input.phonenumber}"], "callbackScheduledTime": "", "countryCode": "", "validateCallbackNumbers": true, "data": {}, "callerId": "", "callerIdName": "" } Response { "translationMap": { "id": "$.defaultScripts.CALL.id" }, "translationMapDefaults": { "id": "\"\"" }, "successTemplate": "{\"id\": ${id}}" }
Response
Charaf | 2023-08-27 15:23:18 UTC | #6
Based on your screenshot, it seems you are trying to get the scriptId by making an API call using the following API: `POST /api/v2/conversations/callbacks `
As mentioned in my previous answer, you should initiate a GET request to `/api/v2/routing/queues/{queueId} `. Once you get the scriptId, you can then use it as an input to create a callback.
Best regards,
Charaf
Guy_Brown | 2023-08-29 17:45:50 UTC | #7
Sorry, sometimes I cannot get out of my own way. It is working now. Thank you.
system | 2023-09-29 17:45:53 UTC | #8
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: 21676