Artisan IMG > Greenbits (greenbits) (3da61b7f-2e38-4b08-a01b-2e0299230c5d)
Artisan IMG > Greenbits (greenbits) (3da61b7f-2e38-4b08-a01b-2e0299230c5d)

Greenbits

Greenbits dispensary POS software simplifies the complexities of cannabis commerce, making regulated retail function like regular retail.

Overview
Copy

Greenbits simplifies the complexities of regulated retail, empowering you with essential retail management tools such as their dispensary POS software. This enables you to optimize operations and maximize performance, allowing cannabis commerce to be safer, smarter, and easier for everyone.

API INFO: The Base URL used for the Greenbits connector is https://api.greenbits.com/api/v1. More information can be found on their main API documentation (v1.0) site.

Authentication
Copy

When using the Greenbits connector, the first thing you will need to do is go to your Tray.io account page, and select the workflow you wish to work on. Once in the workflow builder itself, search and drag the Greenbits connector from the connectors panel (on the left hand side) onto your workflow.

With the new Greenbits connector step highlighted, in the properties panel on the right, click on the Authenticate tab and 'Add new authentication' (located under the 'Authentication' field).

This will result in a Tray.io authentication pop-up window. The first page will ask you to name your authentication, and state which type of authentication you wish to create ('Personal' or 'Organisational').

As you can see, the next page asks you for your 'API Token' credentials.

In order to get this field, you will need to send a GET request to the Greenbits API. You can do this using an API development environment such as Postman.

You can follow the Greenbits API documentation v1, to find the exact format that the API development environment will be expecting for the request.

As part of this request, you will have to input 'Username' and 'Password' fields in Postman (or whichever API development environment you chose to use). These should be your current authentication details used to login to your Greenbits account.

Your token will be returned in the request's response:

Once you have added this field to your Tray.io authentication popup window, click on the 'Create authentication' button.

Go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the drop-down options now available.

Your connector authentication setup should now be complete.

Using the Raw HTTP Request ('Universal Operation')
Copy

As of version 1.0, you can effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in Greenbits which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the Greenbits API documentation v1.0, to find the exact format that Greenbits will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base URL will be automatically set (the base URL is picked up from the value you entered when you created your authentication).

The base URL for Greenbits is: https://api.greenbits.com/api/v1

For example, say that the 'Get Products' operation did not exist in our Greenbits connector, and you wanted to use this endpoint, you would use the Greenbits API docs to find the relevant endpoint - which in this case is a GET request called: /products.

More details can be found here.

As you can see there is also the option to include a query parameter, should you wish to do so. So if you know what your method, endpoint and details of your query parameters are, you can get the product information with the following settings:

Method: GET

Endpoint: /products

Query Parameter: Key: by_brand Value: Khush kush

Final Example outcome being: https://api.greenbits.com/api/v1/products?by_brand=Khush%20kush

Example Usage
Copy

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and the greenbits connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the Greenbits connector, to fetch a list of customers of your choice and then add the retrieved list to a CSV file.

  1. Setup using a manual trigger and using the Greenbits connector fetch a product and its details based on the specified Product ID.

  2. List similar products as your previously selected product.

  3. Create a CSV file.

  4. Loop through the products collection from the 'List similar products' step (using the Loop connector) to populate the rows in your CSV file.

  5. Export the populated CSV file.

Your completed workflow should look similar to this:

1 - Setup Trigger & Get Product Operation
Copy

Select the Manual trigger from the trigger options available.

From the connectors panel on the left, add a Greenbits connector to your workflow. Set the operation to 'Get product'. You can then select a product of your choice from the available dropdown options .

Feel free to re-name your steps as you go along to make things clearer for yourself and other users. The operation names themselves often suffice.

You have now set up your workflow to retrieve information on a specific Greenbits product.

2 - List Similar Products
Copy

Next, search for another Greenbits connector within your connector panel, and drag it into your workflow as your next step. Set the operation to 'List products'.

This operation allows you to search for products using query parameters. In this example, we will use it to return similar products to the product we chose within the previous Greenbits connector step.

In order to return a list of similar products, start by using the mapping icon (found next to the 'By category' input field, within the properties panel) to generate the connector-snake.

While hovering over the 'Get product' step (with the tail end of the connector-snake), select category_id from the list of output properties displayed. This will auto-populate a jsonpath within your 'By category' input field, and update the type selector to jsonpath.

In the simillar way as specified above, you can find the jsonapth for the 'By product type' feild from the 'Get product' step. It should appear simillar to $.steps.greenbits-1.product.product_type_id

For more clarification on the pathways you have available, open the Debug panel to view your step's Input and Output.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our pages on Basic data concepts and Mapping data between steps

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

In your Output panel you will now see a list of all of the products with the same category and product type as the product you selected in step 1.

3 - Create & Populate a CSV file
Copy

In this step you will be creating a CSV file, which you will then populate in the following step. First, search for the CSV Editor connector within your connector panel, and drag it into your workflow as the third step. Set your operation to 'Create CSV'.

Make sure the 'Scope' input field is set to 'Current Run'.

Next, on the input panel, specify total number of clumns you wish to add in the 'Number Of Columns' field and name the columns. In this example we have added three columns namely name, sell_price, and quantity (do not worry about adding rows for now, you will be adding these in a later step).

You have now created a base CSV file with 3 columns for your data.

Next, search for the Loop collection connector within your connector panel, and drag it into your workflow as your next step. Set your operations to 'Loop list'.

The Loop Collection connector allows you to iterate through a list of results. In this example, we will use it to iterate through the data found within the previous Greenbits connector step.

In order to specify the list you want to loop through, start by using the list mapping icon (found next to the list input field, within the properties panel) to generate the connector-snake.

While hovering over the 'List products' step (with the tail end of the connector-snake), select products from the list of output properties displayed. This will auto-populate a jsonpath within your list input field, and update the type selector to jsonpath.

After this, the next step is to drag another CSV Editor connector inside of the Loop Collection step itself. Set the operation to 'Add Row'. As you can see, the 'CSV ID' and 'Cell Values' fields are required.

Using the connector-snake find the jsonpath for the 'CSV ID' field from the 'Create CSV' step. It should appear similar to $.steps.csv-1.id.

USER TIP: Please note that the 'Cell Values' property names should match with the columnnames you provided in the previous step.

In order to populate your CSV rows, using a connector-snake find the jsonpath for all the specified columns (name, sell_price, and quantity) from the 'Loop products' step.

The CSV file has now been formatted to include rows with specific data from the 'List similar products' step.

4 - Export your CSV File
Copy

The last step is to drag a final CSV Editor connector into your workflow. Set the operation to 'Export CSV'. As you can see, the 'CSV ID' and 'Filename' fields are required.

This final step allows you to export an in memory CSV into a file for persistance and potential use elsewhere (e.g in another workflow).

And there you have it! You have fully completed the Greenbits tutorial and should now have a workflow which processes data from Greenbits and stores it into a CSV.

BEST PRACTICES: Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as: