Jump to content

Loyverse and ChatGPT Integration using Zapier


Mark_Happy

Recommended Posts

Loyverse-ChatGPT Integration using Zapier

 

            Utilizing AI to help improve business by analyzing the sales. In this Zapier integration, basically, there will be 3 steps/portions that need to be set up. Setting up Automatic Zap to get sales/receipts from previous month and then have them be in Google Sheets, Cleaning the data and aggregating them to prepare for AI Analysis and finally, have the AI analyze it and send its output through an outlet.

 

First step/portion that needs to be set up is the Integration between Loyverse and Google Sheets so that the sales data can be stored for use on AI later on. Additionally, you will also need to prepare a spreadsheet in Google Sheets to have the sales of Loyverse be placed.

1.)   Go to Zapier and click on the Create button to create a Zap
2023-12-16_12h20_44.png.d4aacc33da415e2c64a5b66c31691999.png

2.)   Add a trigger onto the Zap and select Schedule

image.thumb.png.db70efbce6b0711b3244262760417152.png

3.)   Then, set the “Event” to Every Month and press continue.

image.thumb.png.ec623bdfe70c510c3f02338cc483f60d.png

4.)   Create 5 Formatter Actions provided by Zapier. These are necessary in order to be able to create a date and use it to retrieve the sales within that date. The first 3 actions, use the “Date/Time Event”.

image.thumb.png.b46e03d11ff038f9e2da5550db7ca75d.png

image.thumb.png.31ce1919f7d2339ddf390803113c0d33.png

image.thumb.png.ec6c055c8d4e172f237ddc78a166554a.png

5.)   The first action transforms the current date retrieved to the next month for use on later actions. Set the Action and select in “Transform” dropdown field to “Add/Subtract Time”. On the “Input” field, use Zapier’s function of {{zap_meta_human_now}}. This function gets the current date and time. (For more information, check out the link at https://help.zapier.com/hc/en-us/articles/8496275717261-Insert-the-time-your-Zap-runs-into-a-field ). Then, on the “Express” field, set it to “+1 month” and the “To Format” field to the following format: “YYYY-MM-DDTHH:mm:ss.sssZ”.image.thumb.png.46505d3ab7adfb645400d3233b9539fc.pngimage.thumb.png.17b6a7ea3d03c894d29de5bd25bce41f.png

6.)   The second and third actions have the same set up with the first one where it will be setting up the Transform field to Add/Subtract Time. Then, the Input field will be different for these 2 where it will be inputted as the output of the first action.image.thumb.png.3ae544bec42b6f24792d184b14a25c90.png

7.)   Next, on the second action, in its Expression field, set it up as “-1day”. This will be for the purpose of getting the last day of the month. Set the Format to this: YYYY-MM-DD HH:mm:ss Z.

image.thumb.png.89b0da38acd540478476dc127af9ebfc.png

8.)   On the 3rd action, the Expression will be as “-1 month”. This action will retrieve the first day of the previous month.image.thumb.png.4d9707056667402509f93c56b4ad0216.png

9.)   Create the 2 remaining Formatter actions. These 2 actions will be for formatting the date and time format to this specific format: “YYYY-MM-DDTHH:mm:ssZ” as this is what is accepted format for Loyverse API. Set the Event to “Text” and then the Action Transform field to “Replace”2023-12-11_11h06_41.png.7b6bc77f518c95999457be00cea2c397.png2023-12-11_11h06_59.png.c996f985d7f1c2713b9e41904ef50ba7.png

10.)                On each of these 2 action’s input fields, use the appropriate outputs to convert the date to the correct format. For example, the input field on the fourth action is set to the output on the third action that converts date to last day of the month. Set the “Find” to “-0000” and the “Replace” to “Z”.

image.thumb.png.3e38081c94d2b2a44c5b48ef325fdbb5.png

11.)                Add Loyverse Action onto the Zap by searching for it in the search field and choose “Get List of Receipts”.image.thumb.png.66682f8d4df043ac374679d634ab0530.png

12.)                On its Action, set the Created At Min and Created At Max as these 2 fields will allow for Loyverse API to look for the receipts that is between the dates inputted. Use the outputs of the last 2 format actions you’ve set up.image.thumb.png.377661819618a9703e5fc3431a083750.png

13.)                Add another Action from the Formatter Action of Zapier and set its Event to “Utilities” and its Action Transform field to “Line Itemizer (Create/Append/Prepend)”.

image.png.10326716d9cf8a92dba7a39aa905e7d2.pngimage.png.70a708e31a3de793e4f275ef0f99eea3.png

14.)                On the “Line Item Properties” field, add the following line items: “item name”, “price”, “cost”, “quantity”. And set it to the appropriate output given from Get List of Receipts Loyverse action.

image.thumb.png.010941db3f5ca7e27f751a0d679576ca.png

15.)                Add Google Sheets action, and set the Event to “Create Multiple Spreadsheets Rows” and set the Drive, Spreadsheet and Worksheet fields to the appropriate Spreadsheet file you prepared to place the data and then on the Rows field, place the appropriate outputs.

image.thumb.png.f644beba886e5ab6b1551308e345a292.png

After creating the 1st step/portion, the 2nd step/portion of this is to create another Zap that checks a trigger from when a new Worksheet is created in an existing spreadsheet. We need to create this first so that when we use Pivot Table feature in Google Sheets, it will be considered a new Worksheet to which it can be triggered and thus allow the AI to analyze the sales.

1.)   Bearing in mind the previous Zap created, search and select Google Sheets as Trigger and select the Event as “New Worksheet”.image.thumb.png.e486ec263cc7e8381111cfde840823f5.png

2.)   The next action, select the Google Drive action and select the Event field as “Find a File”. And then input in “File Name” field the name of the prepared Google Sheets that contains the sales/receipts info. And select the drive that this spreadsheet can be found.image.thumb.png.ca081e7a0d8c047514759ac39c12d5c5.pngimage.thumb.png.d0c5ed53409a31bd092a4e3b17c1d3ec.png

3.)   Create another action and use the Formatter action. Set the Event field as Utilities and choose the Transform field to “Import CSV File”. This is so that we can get the Spreadsheet created earlier that contains the sales/receipts from the first Zap. Finally, set the “CSV File” file to the File Csv output given from the Find a File Google Drive Action set up in the previous step.

image.thumb.png.867e4974cfe37ce85737fdea74d65ad4.png

image.thumb.png.f8640883f597db15b2569eaa8b23324a.pngimage.thumb.png.392209f75193528f0f8f325a8da59d51.png

4.)   Lastly, add the ChatGPT (OpenAI) action and set Event field as “Conversation With Assistant”. Set your desired message and the preferences on how AI would analyze the data/sales/receipts. Don’t forget to add the actual Data/Sales/Receipts that the AI must use to analyze which is the Output from the Previous Step.image.thumb.png.e737708173f97282f3b0614c2d4b9287.pngimage.thumb.png.b490d2492a11d387a90cf15bc767f7f0.png

5.)   Don’t forget to add the final action on the 2nd Zap which is to send the analysis of AI to your Gmail. This can be in any platform you would like to have the analysis be sent to but for the sake of simplicity, we will be using Gmail action. Set it up as Event “Send Email” and place the analysis in the Body Field:

image.thumb.png.be14c7c4f2f8df5b878dc5cf93c4c188.png

And that is the 2nd portion done! It may be daunting at first but once everything is set up, it is a very simple integration that anyone can do! Moving on to the final portion, in Google Sheets, manually clean the data up using the Pivot Table feature provided by Google Sheets. This will be a quick and simplified explanation of how to use Pivot Table specifically in this integration flow, if more information is needed, head on over to Google’s official site explaining how Pivot table works, click the link at https://support.google.com/docs/answer/1272900?hl=en&co=GENIE.Platform%3DDesktop .

 

1.)   Click the Insert button and click on the Pivot Table. It will create a new Worksheet that would be named “Pivot Table 1” or etc.image.thumb.png.4e0c52f4eb82938190b2b06dc922b446.png

2.)   Move the Pivot Table Worksheet to the very front as this is what is recognized by the Trigger on the 2nd Portion/Step we set up earlier.image.thumb.png.aac14f75a0a8159f4323160a2e86f2f1.png

3.)   A neat feature that Pivot Table has is that it will automatically remove duplicates for you and then allow you to sum up all values that were the same. So proceed to add the necessary information such as the aggregated Item Name, Sum of the Price, Cost, and Quantity by clicking on the Add button on the Right side called Pivot Table Editor.

image.thumb.png.c5657f59a35965b7146170b86858a175.pngimage.thumb.png.ea897d75edd028ba1eaa8c8ee28a6dfc.png

 

 

            This is the power of Integration that can be provided with Integrator platforms like Zapier! And the wonderful aspect to this is that it is very flexible and easy to modify to suit whatever needs a business owner has.

Link to comment
Share on other sites

Loyverse Point of Sale

 

 

 

 

×
×
  • Create New...