Legacy Dev Forum Posts

 View Only

Sign Up

Custom Action - Create Callback

  • 1.  Custom Action - Create Callback

    Posted 06-05-2025 18:40

    Ana_Laia | 2018-03-28 15:51:28 UTC | #1

    Hi everyone,

    In our contact center, we are thinking of creating schedule callbacks in IVR.

    For this, it was suggested to use a custom Pure Cloud data dip action: https://community.genesys.com/communities/community-home/digestviewer/viewthread?GroupId=19&MessageKey=733eb26c-24ac-4c74-a525-edffb62b59ba&CommunityKey=bab95e9c-6bbe-4a13-8ade-8ec0faf733d4&tab=digestviewer&ReturnUrl=%2fcommunities%2fcommunity-home%2fdigestviewer%3fcommunitykey%3dbab95e9c-6bbe-4a13-8ade-8ec0faf733d4%26tab%3ddigestviewer#bm4

    Therefore, I created PureCloud Data Action to use POST /api/v2/conversations/callbacks using as input a queue id, a scheduled time and a phone number and the configurations below. However when I tried to test it, an error occurred.

    Input contract: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Creat IVR Callback", "description": "Creat a callback", "type": "object", "properties": { "queueId": { "description": "The queue ID.", "type": "string" }, "callbackScheduledTime": { "description": "The callback schedule time", "type": "string" }, "callbackNumbers": { "description": "The callback number.", "type": "number" } } }

    Output contract: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Create Callback", "description": "Create a callback", "type": "object", "properties": { "conversationId": { "description": "Conversation id checkup", "type": "string", "title": "" } } }

    Request Configuration: { "requestUrlTemplate": "/api/v2/conversations/callbacks", "requestType": "POST", "headers": { "UserAgent": "PureCloudIntegrations/1.0", "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "${input.rawRequest}" }

    Response Configuration: { "translationMap": { "conversationId": "$.results[0].conversation.id" }, "successTemplate": "{\n \"conversationId\": ${conversationId}\n}"

    Test output result: { "status": 500, "code": "internal.server.error", "message": "The server encountered an unexpected condition which prevented it from fulfilling the request.", "messageParams": {}, "contextId": "5fcbf54b-e3f2-4b77-97c1-002fe3d43d54", "details": [], "errors": [ { "status": 415, "code": "INTERNALSERVERERROR", "message": "REST call for action execute failed. Message:Request to backend service failed. To see error details, execute request in Postman, or other REST tools. [5fcbf54b-e3f2-4b77-97c1-002fe3d43d54] [5fcbf54b-e3f2-4b77-97c1-002fe3d43d54]", "messageParams": {}, "details": [], "errors": [] } ] }

    Can you help me to figure out what's happening? This is new to me, so I can be missing something here...

    Thank you in advance.

    Best regards, Ana Laia


    Jason_Mathison | 2018-03-28 14:32:16 UTC | #2

    It looks like this request header is causing trouble: "Content-Type": "application/x-www-form-urlencoded"

    Try removing it.


    Ana_Laia | 2018-03-28 14:58:39 UTC | #3

    Hi Jason.

    Thank you for your answer.

    I removed the request header an tried to test it. However another error occurred.

    New Request Configuration: { "requestUrlTemplate": "/api/v2/conversations/callbacks", "requestType": "POST", "headers": { "UserAgent": "PureCloudIntegrations/1.0" }, "requestTemplate": "${input.rawRequest}" }

    Test output result: { "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "f953a25f-7964-437f-bf97-8efc0231fedf", "details": [], "errors": [ { "status": 400, "code": "BAD_REQUEST", "message": "REST call for action execute failed. Message:Request to backend service failed. To see error details, execute request in Postman, or other REST tools. [f953a25f-7964-437f-bf97-8efc0231fedf] [f953a25f-7964-437f-bf97-8efc0231fedf]", "messageParams": {}, "details": [], "errors": [] } ] }

    Regards, Ana


    Jason_Mathison | 2018-03-28 15:52:48 UTC | #4

    So the specific problem that you seem to be having is that the API is expecting an array of strings for callback numbers and you are providing a single "number". This can be solved by changing the input contract to take a string type for your callbacknumbers and change your request template to wrap the callbacknumbers with an array:

    "requestTemplate": "\"queueId\": \"${input.queueId}\" \"callbackScheduledTime\": \"${input.callbackScheduledTime}\" \"callbackNumbers\": [\"${input.callbackNumbers}\"]"


    Ana_Laia | 2018-03-28 16:15:30 UTC | #5

    I changed the input contract to:

    However, when I tried to change the request configuration I got an syntax error:

    Regards, Ana


    Ana_Laia | 2018-03-28 17:06:21 UTC | #6

    Update:

    I followed this topic https://developer.mypurecloud.com/forum/t/creating-action-requesttemplate-with-multiple-inputs/2000/3

    And change the Configuration Request to:

    This time I didn't have any syntax error, however when I tried to test it I got the same output result:

    { "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "3fba6dd9-428a-455d-81a3-3a756a5e741b", "details": [], "errors": [ { "status": 400, "code": "BAD_REQUEST", "message": "REST call for action execute failed. Message:Request to backend service failed. To see error details, execute request in Postman, or other REST tools. [3fba6dd9-428a-455d-81a3-3a756a5e741b] [3fba6dd9-428a-455d-81a3-3a756a5e741b]", "messageParams": {}, "details": [], "errors": [] } ] }


    Jason_Mathison | 2018-03-29 16:56:54 UTC | #7

    Sorry, the forum apparently altered what I pasted yesterday. Let's try this:

    {
      "requestUrlTemplate": "/api/v2/conversations/callbacks",
      "requestType": "POST",
      "headers": {},
      "requestTemplate": "\"queueId\": \"${input.queueId}\" \"callbackScheduledTime\": \"${input.callbackScheduledTime}\"  \"callbackNumbers\": [\"${input.callbackNumbers}\"]"
    }

    Ana_Laia | 2018-04-02 08:55:08 UTC | #8

    Hi Jason,

    I changed the Configuration Request as you suggested and saved without any problem.

    However, when I tried to test I got the same error.

    { "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "2bfe40dc-7b51-4fcc-afdf-1a2d8a284773", "details": [], "errors": [ { "status": 400, "code": "BAD_REQUEST", "message": "REST call for action execute failed. Message:Request to backend service failed. To see error details, execute request in Postman, or other REST tools. [2bfe40dc-7b51-4fcc-afdf-1a2d8a284773] [2bfe40dc-7b51-4fcc-afdf-1a2d8a284773]", "messageParams": {}, "details": [], "errors": [] } ] }

    I also test it with and without "Flatten output" flag with enabled, and I got the same error.

    Regards, Ana


    Jason_Mathison | 2018-04-02 13:48:20 UTC | #9

    I did test this out and get it working a few days ago. The part that threw me the most was getting a working callback Scheduled time. What values are testing with?


    Ana_Laia | 2018-04-02 14:00:44 UTC | #10

    I'm testing with the same values that I use on https://developer.mypurecloud.ie/developer-tools/#/api-explorer (it returns 202 Accepted)

    ![image

    528x187](upload://r7G43FyJp0fdKGgt4Fm1i9GciRq.png)

    ![image

    631x200](upload://uDoho5SGOsUXbKrAHInaBPOAOof.png)

    { "queueId": "7c6ee261-4771-46b8-a038-c6f843bd9fec", "callbackNumbers": [3512111111111], "callbackScheduledTime":"2018-04-02T15:07:13Z" }

    On custom action:

    ![image

    690x272](upload://4BnksnV46qOoebPq7XI3H1gLgiA.png)

    ![image

    630x396](upload://c5O9yu3sukJUyRhTfOB7iES2jAO.png)

    Tell me if you need more details.


    Jason_Mathison | 2018-04-02 15:08:45 UTC | #11

    Alright, I had to make a few more corrections to get this working.

    Here is my new request configuration. Somehow my previous version was missing the outer {} as well as commas between things in the request template. I have no idea how I though that this was working before.

    {
      "requestUrlTemplate": "/api/v2/conversations/callbacks",
      "requestType": "POST",
      "headers": {},
      "requestTemplate": "{\"queueId\": \"${input.queueId}\", \"callbackScheduledTime\": \"${input.callbackScheduledTime}\",  \"callbackNumbers\": [\"${input.callbackNumbers}\"]}"
    }

    And here is my response configuration, your version appeared to expect a results array, which is not what I was seeing.

    {
      "translationMap": {
        "conversationId": "$.conversation.id"
      },
      "successTemplate": "{\"conversationId\": ${conversationId}\n}"
    }

    Ana_Laia | 2018-04-02 16:21:36 UTC | #12

    It worked, thank you for your help Jason :)


    system | 2018-05-03 16:29:00 UTC | #13

    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: 2671