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 visitorExternalId 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 : retrieving "non standard” custom data :

⚠️ If you want to retrieve non-standard custom data (data that does not feed the visitor record) via the API, you must setup your custom data in the iAdvize admin section.

Use the
visitorCustomData query of the GraphQL API to retrieve the custom data.

You will need to fill in the following 3 filters:
  • channel : corresponds to the channel on which the conversation took place (usually it will be the value "CHAT")
  • legacyVisitorId : corresponds to the ID of the visitor you retrieved in the previous step.
  • projectId : corresponds to the ID of your project (also called website or sid)


⚠️ Warning, custom data are only available for 20min after the conversation has been closed.