Retrieve custom data

Category
#CustomData 


flag in hole Objective

Exporting or using custom data during a conversation or at the end of a conversation.

brick What do I need?

memo Step to follow

Before you start

In iAdvize, there are two types of "Custom Data":

  • Standard” Custom Data

They automatically populate the visitor profile information. List of visitor custom data.


For example: cust_email or cust_name will respectfully populate the email and lastname fields of the visitor profile.

 

  • “Non standard” Custom data

All other custom data that you create and setup within iAdvize admin.

Retrieving the visitor ID

Whether you retrieve the "standard" custom data or not, you will necessarily need the visitor's ID.

This will be done differently depending on whether you are in an
"External Bot" or "End of conversation" use case.


1
.
BOT ExternalUse case 

  • When a conversation starts, iAdvize calls the POST /conversations endpoint of the external bot and passes in the body the id of the iAdvize conversation that was created.
  • The external bot can use the conversationid sent in the payload of the previous request to retrieve the legacyVisitorId via the GraphQL conversation query that corresponds to the id of the visitor you are trying to retrieve:



2. “End of conversation” Use case

  • When a conversation is closed, iAdvize calls the webhook v2.conversation.closed and passes information in the playload.
  • One of these fields is the visitorId which is the id of the visitor you are trying to retrieve.

Option 1 : retrieving “standard” custom data:

You just have to make a GET HTTP request on the visitor resource and also specify the visitor ID you just retrieved in the previous step.

For example, the
 GET /visitor/101097152 request will return the fellowing result:

{
"meta": {
     "status": "success"

},
"data": {
      "id": 101097152,
      "unique_id": "912265878d8bf0ffa2b31099aaaf8daf60a2837777136",
      "external_id": "user-aaa-0001",
      "lastname": "DUPONT",
      "firstname": "Jean",
      "address": "",
      "city": "Nantes",
      "zip": "",
      "country": "",
      "phone": "",
      "email": "",
      "browser": "Chrome 90",
      "created_at": "2021-05-17 16:53:56",
      "website_id": 7114,
      "_link": "/visitor/101097152"
     }
}

Option 2: get the "non-standard" custom data:

 

Here is an example of Custom Data in the code.

 

<script type="text/javascript">

//<![CDATA[

window.idzCustomData = {

"computertype": "Mac Book air M1",

"website": "websitename",

"page_name": "welcomepage",

"comma": 123.345,

"value number": 12,

"booleen": true

};

//]]>

</script>


⚠️ If you want to retrieve "non-standard" custom data (those that don't populate the visitor record data) via the API, you need to use the GraphQL API's visitorConversationCustomData query.

 

You will need to fill in the following filter field:

conversationId: value type "e6f2c877-0887-49c1-9ad3-74b1684d0382".

 

You must also select the custom data types (values):

 

  • StringValue: string of any type. Characterized by " in the code (ex: "websitename").
  • IntValue(integer): integer number.
  • FloatValue: number with decimal (without limit after the . of decimal).
  • BooleanValue: binary value type true/false.

 

Select the key and its value.

Capture_d_e_cran_2022-09-21_a__15.02.42.png