Transfer to an external contact number

Hey,

I'm looking for a way to transfer call flow to a external contact phone number with the architect.

Thanks !

Hello,

Unfortunately, the "Search External Contacts" action and the "Get External Contact" action are only available in Architect for email and chat flows - not for voice.
See here: https://help.mypurecloud.com/articles/search-external-contacts-action/
and here: https://help.mypurecloud.com/articles/get-external-contact-action/

Having said that, you could technically invoke a PureCloud DataAction from the Architect flow, that would leverage Platform API and its methods related to ExternalContacts.
See here for the PureCloud Data Action: https://help.mypurecloud.com/articles/about-purecloud-data-actions-integration/
And here for the External Contacts API methods: https://developer.mypurecloud.com/api/rest/v2/externalcontacts/

But this may not be trivial to implement (several API calls/actions and some blocks in Architect flow) depending on what you are trying to achieve.

Would that be an external contact that you know already - I mean for which the external contact identifier (i.e. contactId) could be "hard-coded" in your Architect flow?

Or would that be to perform a search for a contact first? Based on what information: phone number, name of the contact, .... ?
Searching may not be trivial to implement as depending on what you search for, your search request could bring 0 results, 1 result, or multiple ones (quite complex - ex: searching with a lastname and finding different people/contacts with the samelastname).

And would you know upfront which phone number to use? I mean you can define severals in a contact - work phone, home phone, mobile phone, ... - or just one or none.

1 Like

Hey Thanks for the response that's very helpful.

Actually, We need to set up a call flow which has to transfer the call flow to a phone number but which will be updated every weeks by a person from the team. I don't want him/her to update it directly from on the architect for basic security reason. So i was looking for a way to get it via API.

I'm normally not a developer and have a hard time understanding the elements to implement in the data action part.

What I wanted to do was to create an external contact that will always be the same (so same id) but where the phone number will be changed if necessary. This way, teams will only have to change the number on the contact part and not on the architecture.
The architect will be in charge of retrieving the information directly by API action.

Can you tell me more about the different tabs to be filled in, especially the "Contract" & "Configuration" part?

Thanks a lot !

Ok. That makes this a bit easier. So we can assume the contactId is known and we know which phone number (I mea type of phone number) to look for.
Give me maybe a day or 2. Not that it takes this long for the data action :slight_smile: But I need to finish few things and I will try to create this data action in my system to figure out what contract and configuration should be.

In the mean time, you could maybe start with the procedure to setup the PureCloud data action integration (adding the integration in your system - part of the ones exposed in Admin - Integrations after clicking the + icon), create the OAuth client for this integration and associate it with the integration.

Then I'll try to send you info on what to add as Action.

1 Like

Thanks a lot for your help :slight_smile:

By the way, I already have the PureCloud Data Actions integrations set up for an other use. I dont think so, but should I need add another one ? Same for the OAuth client.

meanwhile, I'll try to look at this on my own :slight_smile:

So that is enough. I mean you'll just need to add a data action, pointing to this same integration.
You may need to update the OAuth client for a role/permission that allows to query contacts, if it is not the case already.

Hello,

Here it is.

You will need to check that the OAuth client (Client Credentials Grant) that you re using in your PureCloud Data Actions integration has one role with the following permission:
"externalContacts - contact - View"
If among the roles, that are already assigned to your OAuth client, this permission is not present/assigned in any of them, you can:

  • Modify an existing role and add/assign this permission.
  • Or create a new role with that permission only and add it to your OAuth client roles.

Note that to grant a role to an OAuth client, you must have this role assigned to your profile.

Below are the contracts and configurations I have used.

Note that once you publish a data action, you can get set it back to Draft mode to edit/modify it.
BUT once it has been published (once), you can only change the configurations.
If you need to change the contracts, you will need to create a new Data Action.

Some info on the logic I have implemented below. You can modify it according to your needs.

From the architect flow, you will be able to invoke the data action with the "Call Data Action" block (under Toolbox - Data).

The DataAction will take the contactId as input parameter.
If the contactId which is passed to the data action is invalid (unknown contactId), or if you pass it via a variable with an empty string (by mistake), the Data Action will exit via the Failure path.
Otherwise, if successful, you will exit via the Success path.

I have created output variables for the 4 different possible phone numbers you can provision on a contact - work/cell/home/other phones.
If you have configured a work phone number in your contact, it will be available in the corresponding output (contactWorkPhone).
As it is not mandatory to configure phone numbers on a contact or if only a subset of them were configured, I have managed the lack of phone number the following way.
If you want to retrieve the home phone, and it was not configured/defined in the contact, the output variable (contactHomePhone) will be equal to "UNKNOWN"

If you want to cope with all possible errors, you may want to test the phone variable and check if it is different from "UNKNOWN"
Otherwise, you can use it directly as Number in the "Transfer to Number" block (under Toolbox - Transfer) in the Architect flow.

Input Contract:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Get External Contact By Id",
  "description": "Items needed in the input of the GET Document Content.",
  "type": "object",
  "required": [
    "contactId"
  ],
  "properties": {
    "contactId": {
      "type": "string",
      "description": "Your External Contact Id."
    }
  }
}

Output Contract:

{
  "type": "object",
  "properties": {
    "contactWorkPhone": {
      "type": "string"
    },
    "contactCellPhone": {
      "type": "string"
    },
    "contactHomePhone": {
      "type": "string"
    },
    "contactOtherPhone": {
      "type": "string"
    }
  },
  "additionalProperties": true
}

Input config:

{
  "requestUrlTemplate": "/api/v2/externalcontacts/contacts/#if(($input.contactId)&&($input.contactId!=\"\"))${input.contactId}#{else}invalid#end",
  "requestType": "GET",
  "headers": {
    "Content-Type": "application/json"
  },
  "requestTemplate": "${input.rawRequest}"
}

Output config:

{
  "translationMap": {
    "contactWorkPhone": "$.workPhone.e164",
    "contactCellPhone": "$.cellPhone.e164",
    "contactHomePhone": "$.homePhone.e164",
    "contactOtherPhone": "$.otherPhone.e164"
  },
  "translationMapDefaults": {
    "contactWorkPhone": "\"UNKNOWN\"",
    "contactCellPhone": "\"UNKNOWN\"",
    "contactHomePhone": "\"UNKNOWN\"",
    "contactOtherPhone": "\"UNKNOWN\""
  },
  "successTemplate": "{\n   \"contactWorkPhone\": ${contactWorkPhone}\n, \"contactCellPhone\": ${contactCellPhone}\n, \"contactHomePhone\": ${contactHomePhone}\n, \"contactOtherPhone\": ${contactOtherPhone}\n}"
}

Let me know if you run into an issue.

Regards,

1 Like

Just a new version of input contract and input configuration.
It requires to create a new data action if you already published the previous one once (as I have modified the contracts).

I have moved the management of an empty string for the contactId input parameter, in the input contract (using minLength).

In previous version, I was making that test in the input configuration - replacing the empty string with some invalid token ("invalid") using Velocity.
This means that the PureCloud API request was still made with that invalid token/contactId.

By managing this at input contract level, the Data Action request will fail before issuing the PureCloud API request.

Input Contract:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Get External Contact By Id",
  "description": "Items needed in the input of the GET Document Content.",
  "type": "object",
  "required": [
    "contactId"
  ],
  "properties": {
    "contactId": {
      "type": "string",
      "minLength": 1,
      "description": "Your External Contact Id."
    }
  }
}

Output Contract:

{
  "type": "object",
  "properties": {
    "contactWorkPhone": {
      "type": "string"
    },
    "contactCellPhone": {
      "type": "string"
    },
    "contactHomePhone": {
      "type": "string"
    },
    "contactOtherPhone": {
      "type": "string"
    }
  },
  "additionalProperties": true
}

Input config:

{
  "requestUrlTemplate": "/api/v2/externalcontacts/contacts/${input.contactId}",
  "requestType": "GET",
  "headers": {
    "Content-Type": "application/json"
  },
  "requestTemplate": "${input.rawRequest}"
}

Output config:

{
  "translationMap": {
    "contactWorkPhone": "$.workPhone.e164",
    "contactCellPhone": "$.cellPhone.e164",
    "contactHomePhone": "$.homePhone.e164",
    "contactOtherPhone": "$.otherPhone.e164"
  },
  "translationMapDefaults": {
    "contactWorkPhone": "\"UNKNOWN\"",
    "contactCellPhone": "\"UNKNOWN\"",
    "contactHomePhone": "\"UNKNOWN\"",
    "contactOtherPhone": "\"UNKNOWN\""
  },
  "successTemplate": "{\n   \"contactWorkPhone\": ${contactWorkPhone}\n, \"contactCellPhone\": ${contactCellPhone}\n, \"contactHomePhone\": ${contactHomePhone}\n, \"contactOtherPhone\": ${contactOtherPhone}\n}"
}

Hello Jerome, Thanks for this, it's very helpful !! :slight_smile:
Exactly what i was looking for !

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