Update lastname from user's last email - freshsales

Hello,
I am wanting to check if a contact has their last name set and if not, update it from the last email.
I am writing this in python but that doesnt have any bearing here.

I can see that I can reference the contact via the api
https://domain.myfreshworks.com/crm/sales/api/search?q=user@emaildomain.com&include=contact

which presents me with:
[{“id”:“30002454068”,“name”:“FirstName LastName",“email”:"user@emaildomain.com”,“updated_at”:“2021-08-07T00:30:34+12:00”,“type”:“contact”}]

I would like to extract the actual first name and last name without having to massage the limited output.
As a side exercise, how would you extract a custom field from the contact.

I tried using the FreshsalesAnalytics Python library but it appears you can only update the contact but not view.

What is the best way?

1 Like

Hi @SnapJosh

Welcome to this community :tada:

I think this case can be broken down into the following steps

  1. Find the Contact with no last name
  2. Using the response information, speculate a last name
  3. Update contact information

I guess a couple of ways you can move forward here,

You already got email information from the search API.

To broaden the response you can use query params /api/search?q=[query param]&include=user Will return the user id, name and email Type will be user

or

/api/search?q=[query param]&include=contact Will return the contact id, name, email and avatar(if exists) Type will be contact

Further using update a Contact API you can update the contact.

The above way may require a poll for this information and make these API calls periodically to update the contact information. You can alternatively look for an option to build a Freshworks app that will run within your Freshsales account. The app can observe for every contact that is created and make those API calls to update the contact as well. This is completely hosted by Freshworks you might not need to host a middleware or own system and bear its maintenance if this use case rightly fits.

How would I see the the current last name in FreshSales? Since that field isnt returned in the SearchAPI or is there a way to request specific fields for a user?

Using the search API you would see an ID associated with the contact. It should be possible to use the same ID to consume View A Contact API. The response would contain "last_name": "Sampleton (sample)", property in it.

It appears like it may cost another API call.