♻️Recycling Suggestions

Providing Recycling and Reuse Suggestions with the VitalEarth SDK

Making sustainability accessible and engaging is at the core of the VitalEarth SDK. It allows users to click a picture of an item and receive valuable suggestions on how to recycle it, creative ideas for reuse, or alternative product suggestions. Here's how you can implement these features in your application using the VitalEarth SDK.

Prerequisites

Ensure that you have completed the installation and initialization of the VitalEarth SDK as explained in the previous steps.

Recycling Suggestions

To provide recycling suggestions for a user's item, you can use the recycleItem function:

import { advisorClient } from "vitalearth-sdk";

// Initialize the advisor client
const client = new advisorClient();

// Specify the item's URL or image as base64 object
const itemUrl = "https://example.com/item-image.jpg"; // Replace with the actual item URL or image URL

// Request recycling suggestions (short or long)
const suggestions = await client.recycleItem(itemUrl, "short"); // Use "short" or "long" as the type

console.log("Recycling Suggestions:", suggestions);

Reuse Suggestions

To provide reuse suggestions for a user's item, you can use the reUseItem function:

import { advisorClient } from "vitalearth-sdk";

// Initialize the advisor client
const client = new advisorClient();

// Specify the item's URL or image
const itemUrl = "https://example.com/item-image.jpg"; // Replace with the actual item URL or image URL

// Request reuse suggestions (short or long)
const suggestions = await client.reUseItem(itemUrl, "short"); // Use "short" or "long" as the type

console.log("Reuse Suggestions:", suggestions);

Alternative Product Suggestions

To provide alternative product suggestions based on the user's item, you can use the alternativeItem function:

import { advisorClient } from "vitalearth-sdk";

// Initialize the advisor client
const client = new advisorClient();

// Specify the item's URL or image
const itemUrl = "https://example.com/item-image.jpg"; // Replace with the actual item URL or image URL

// Request alternative product suggestions (short or long)
const suggestions = await client.alternativeItem(itemUrl, "short"); // Use "short" or "long" as the type

console.log("Alternative Product Suggestions:", suggestions);

Explanation of the code for each function:

  1. Import the advisorClient module from the VitalEarth SDK.

  2. Initialize the client object for providing recycling, reuse, or alternative product suggestions.

  3. Specify the item's URL or image in the itemUrl variable.

  4. Use the respective function (recycleItem, reUseItem, or alternativeItem) to request suggestions based on the type ("short" or "long").

  5. The suggestions returned by the SDK can then be displayed to the user, providing them with valuable information on how to make eco-conscious choices.

By implementing these functions in your application, users can easily seek guidance on recycling, reusing, or finding sustainable alternatives for various products, contributing to a more sustainable lifestyle.

Last updated