Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  Create an external contact using the API and custom ID

    Posted 03-03-2023 02:14

    Hello everyone, I was wondering if anyone has tried creating an external contact using the API and using a custom ID. Please see example below:

    Example:
    POST /api/v2/externalcontacts/contacts HTTP/1.1
    Host: api.mypurecloud.de
    Authorization: Bearer **************************************************************************************
    Content-Type: application/json

    {"id":"cdf805f1-8fb9-42b4-9a74-8e9a2d5b9d0g","firstName":"Karel","lastName":"Novak"}

    Response:
    {
      "id": "d9233e0b-b3ee-494b-aca9-82d2d78a1595",
      "firstName": "Karel",
      "lastName": "Novak",
      "modifyDate": "2023-03-03T07:06:05Z",
      "createDate": "2023-03-03T07:06:05Z",
      "type": "curated",
      "selfUri": "/api/v2/externalcontacts/contacts/d9233e0b-b3ee-494b-aca9-82d2d78a1595"
    }

    Is it even possible to use a custom ID when creating a contact? We would like to do this for the sake of easier and more unambiguous mapping of the contact to the customer's CRM ID. The API responses with different ID and the one used to create the contact was ignored.

    Thank you 


    #Implementation

    ------------------------------
    Martin Myska
    NTT Czech Republic s.r.o
    ------------------------------


  • 2.  RE: Create an external contact using the API and custom ID

    Posted 03-03-2023 10:33

    Martin,

    I may be wrong here, and you might be better asking this one over on the developer forums, but it is my understanding that Genesys Cloud always assigns the ID, for everything. This is because these are GUIDs (Globally Unique IDs) and they have to be certain no to entities gat the same one. (Both within an ORG and between ORGs).

    You will find that even between objects types, there is no duplication (say an Interaction ID and a User ID)

    So, I don't think you can do this for any object type.

    HTH



    ------------------------------
    Paul Simpson
    Eventus Solutions Group
    ------------------------------



  • 3.  RE: Create an external contact using the API and custom ID
    Best Answer

    Posted 03-03-2023 11:25

    For sure.

    First of all you should create a custom field.

    In my environment I used "identifier" because is also searchable. You can find list here: https://help.mypurecloud.com/articles/custom-field-types/

    You can create in: Admin -> Directory -> External Contacts in "Custom Contact Types" choosing as "field Type" the field identifier

    I create field with name "identifier" and field label "id"

    Than import the following Data Action to create External Contact. You shoud use in XXXXXXXXXXXXXXX the id of the custom field that you create.

    {
      "name": "Create External Contact - Exported 2023-03-03 @ 17:14",
      "integrationType": "purecloud-data-actions",
      "actionType": "custom",
      "config": {
        "request": {
          "requestUrlTemplate": "/api/v2/externalcontacts/contacts",
          "requestType": "POST",
          "headers": {
            "Content-Type": "application/json",
            "UserAgent": "PureCloudIntegrations/1.0"
          },
          "requestTemplate": "{\n  \"firstName\": \"${input.firstName}\",\n  \"lastName\": \"${input.lastName}\",\n  \"schema\": {\n    \"id\": \"XXXXXXXXXXXXXXX\",\n    \"version\": 7,\n    \"selfUri\": \"/api/v2/externalcontacts/contacts/schemas/XXXXXXXXXXXXXXX/versions/7\"\n  },\n  \"customFields\": {\n    \"id_identifier\": \"${input.id_identifier}\"\n  }\n}"
        },
        "response": {
          "translationMap": {
            "externalContactId": "$.id"
          },
          "translationMapDefaults": {},
          "successTemplate": "{\n   \"externalContactId\": ${externalContactId}\n}"
        }
      },
      "contract": {
        "input": {
          "inputSchema": {
            "title": "Ext Contact creation Request",
            "type": "object",
            "properties": {
              "firstName": {
                "type": "string"
              },
              "lastName": {
                "type": "string"
              },
              "id_identifier": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        },
        "output": {
          "successSchema": {
            "title": "externalContactId",
            "type": "object",
            "properties": {
              "externalContactId": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        }
      },
      "secure": false
    }


    ------------------------------
    Enrico Preite
    Vodafone Procurement Company S.a.r.l.
    ------------------------------



  • 4.  RE: Create an external contact using the API and custom ID

    Posted 03-03-2023 11:36

    Hi Enrico, thanks a lot. As you describe, we have the solution currently implemented. However, when creating a contact using the POST method, the ID parameter on the developer center is listed as optional in the parameter documentation, so I thought (I was wondering that) it might be possible to use a custom ID. Just like Genesys Engage could :). So now I know it's not possible. Thanks a lot.
    Martin



    ------------------------------
    Martin Myska
    NTT Czech Republic s.r.o
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources