This is a simple example project that demonstrates how to fetch Yosemite National Park activities from the National Park Service API and add them to ThetaEdgeCloud for use in a chatbot knowledge base. The data is automatically updated every 10 minutes.
- Create a NPS API key here https://www.nps.gov/subjects/developer/get-started.htm
- Create a Theta Edge Cloud API Key by going to this link, select your project and click on "Create API Key"
- Clone this repository
- Install dependencies:
npm install
- Create a
.env
file with your API keys:NPS_API_KEY=your_nps_api_key_here # ThetaEdgeCloud configuration TEC_API_KEY=your_tec_api_key_here CHATBOT_ID=your_chatbot_id_here PROJECT_ID=your_project_id_here
To start the crawler that fetches and updates activities data every 10 minutes:
npm start
This will:
- Fetch activities data from the NPS API for Yosemite National Park
- Process the data to extract relevant information
- Convert the data to CSV format
- Generate SQL schema metadata for the data
- Upload the data to ThetaEdgeCloud as a document
- Store the document ID in memory for future updates
- Automatically update the data every 10 minutes
You can also run a single fetch and update operation:
npm run fetch
- The crawler fetches activities data from the National Park Service API
- The data is processed to extract relevant information
- The processed data is converted to CSV format
- SQL schema metadata is generated for the data
- The CSV data is uploaded to ThetaEdgeCloud with the metadata
- The process repeats automatically every 10 minutes
NB: You can also send a plain text file to Theta Edge Cloud. If you do so, add a description field to the metadata object.
The project uploads two types of information to ThetaEdgeCloud:
-
CSV Data: Contains information about Yosemite activities including:
- Activity title and description
- Activity type (hiking, camping, etc.)
- Location within Yosemite
- Seasonal availability
- Reservation requirements
- Pet permissions
-
SQL Schema Metadata: Provides structure for the data:
query_type
: Indicates this is SQL-queryable datasql_schema
: Defines the table structure with column names and typessql_description
: Provides a description of the data
The project includes the following ThetaEdgeCloud API functions:
createDocument
: Creates a new document in ThetaEdgeCloudupdateDocument
: Updates an existing document in ThetaEdgeCloudfetchDocument
: Fetches a document from ThetaEdgeCloudfetchDocumentsList
: Fetches a list of documents from ThetaEdgeCloud