Articles on: Make.com

Labels: how to add labels to TimelinesAI chats from Google Sheets data

via Make.com

This flow searches TimelinesAI chats by phone number and first name from the Google Spreadsheet and adds the desired label to found chats. The flow works the best with sheets: up to 50 rows and a column that contains contact's first name. Skipping the search by first name is highly unrecommended.

Recommended format for a Google Sheet ( columns in red are required):



Create a new scenario at Make.com
Click + to create the first module: search for and select Google Sheets > Search Rows
Configure the new _Search Rows :
Connection: establish the connection with your Google account using on-screen instructions at Make.com
Enter a Spreadsheet ID and Sheet Name: select Select from all
Spreadsheet ID : enter spreadsheet ID that contains your data. Note: your spreadsheet must be publicly available for view and editing. To find your ID open the spreadsheet at Google Drive. Check the URL. Example: https://docs.google.com/spreadsheets/d/1NGKNEFmVaidVgFLwufrYERRNgFEkDzVL44gdPWgwy42Avw/edit#gid=0 . The 1NGKNEFmVaidVgFLwufrYERRNgFEkDzVL44gdPWgwy42Avw part will be the ID .
Sheet Name : select your sheet name
Table contains headers: select Yes if your table contains headers.
Column range : select the range of columns that contain your data. Make.com usually detects this automatically.
Filter, sort order and order by : leave empty or as is
Maximum number of returned rows : enter 50
Right-click the newly created module and select Run this module only . This gets data from the 50 first rows in your sheet. Further steps require output data from this to be present. Make sure you've run the module and have data in the payload:

Add a new HTTP module: The purpose of this step is search TimelinesAI chats by the phone number and name from your Google Sheet. To add this new module click the + icon next to the existing Search Rows module > search for and select HTTP module > then select Make a request
Configure the new HTTP module:
URL: add https://app.timelines.ai/integrations/api/chats
Method: select GET
Headers: add Authorization Bearer XXXX where XXXX must be replaced by your own token from https://app.timelines.ai/integrations/api/

Query String: add 2 items. Item1: Name = group, value = false. Item2: Name= name, value= click the field. A new box will appear to the right with data available from the Search Rows module. Find column where you store people's First Names and add it as a value
Body type: select Raw
Content type: select JSON
Request content: leave empty
Parse content: select YES
Right-click the newly created module and select Run this module only . This will search your TimelinesAI chats. Further steps require output data from this to be present. Make sure you've run the module and have data in the payload:
Add a new Iterator module. The purpose of this module is to handle the search results from TimelinesAI. To add the module click + sign after existing HTTP module > type and select Flow Control > then select Iterator
Configure Iterator: add following into the module {{toArray("XXX")}} . Where XXX is to be replaced by the chats data from your HTTP module like this:

Add a new Set Multiple Variables module. The purpose of this module is to fetch only the chat ID and Phone number from the output of the Iterator. To add the module click + sign after existing HTTP module > type and select Tools > then select Set multiple variables
Configure Set Multiple Variables module
add the first variable. Name= type in ID. Value: type {{get()}} > place the cursor between the circular brackets and select the the value 1 from the Iterator module:

You should get the following line as a result:
Place the cursor between square brackets and type in id .
in the same manner add a 2nd variables named Phone. 2nd variable should have phone between between square brackets

Right-click the newly created module and select Run this module only . Type in any data and make sure you have the output.
Add a new Router module. The purpose of this step is dividing the flow into 2 branches: If the chat with given phone number and name was found and if the chat was not found. To add a Router click the + sign after Iterator > find Flow Control > and then select Router
Setup the filter for the first branch:

Give your filter the desired name . Ex: if name and phone number matches
Set the route as a fallback: select No.
Configure the condition:

Setup the filter for the second branch. For this filter you can give a name and simply select "Yes" for " Set the route as a fallback" . Conditions are not needed:

Setup the final module for the first branch. Click the + sign after the 1st condition (if name and phone number matches) > type and select HTTP Request
URL: add https://app.timelines.ai/integrations/api/chats/XXX/labels, where XXX is to be replaced by your own ID from "Set multiple variables" module
Method : select PUT
Headers : name = Authorization , value = Bearer XXX, where XXX is to be replaced by your own token from https://app.timelines.ai/integrations/api/
Body type: select Raw
Content type: select JSON
Request content: add {"labels": ["XXX"]}, where XXX is to be replaced by the desired label value. If you are passing the value in your Excel file you can insert this data from payload. Alternatively you can simply type in the desired label instead of XXX:

Setup the final module for the second branch. Click the + sign after the 2nd condition > type and select Google Sheets > then select Update a Row
Configure the path to your original spreadsheet
Select the Row number from payload
Add data to the new column. For example a note to yourself that the label could not be added, since the flow could not find the contact from your sheet in TimelinesAI chat list

Save your changes and active the flow

End results: The flow searches TimelinesAI chats by the first name and phone number from Google Sheet > if the chat is found the flow assigns that chat a desired label in TimelinesAI > if the chat is not found the flow modifies the row in Google Sheets and adds a note that the chat could not be labeled.




Updated on: 19/02/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!