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?
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
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"
@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
Best regards,
Charaf
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
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
Sorry, sometimes I cannot get out of my own way. It is working now. Thank you.
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.