Production vs Test Environments

In Cloud Functions… we will maintain 2 deployed versions, hip-log-bot-cf for production and hip-log-bot-cf-test for testing

In Firestore… we will maintain two versions, which are implemented as two separate collections, Users for production and UsersTest for testing. These will be configured 1:1 with the corresponding Cloud Function

In Dialogflow… we only get one Agent per project so we when we want to test from DialogFlow or Messenger, we will toggle the setting (”fulfillment webhook url”)

Untitled

Cloud Functions

Prereqs

  1. Must have gcloud cli installed (and PATH updated to include it)

Deploy to Test Environment

  1. cd to the source code folder hip-log-bot-cloud-function/src/
  2. Deploy with this command -
gcloud functions deploy hip-log-bot-cf-test \
--gen2 \
--runtime=python311 \
--region=us-central1 \
--source=. \
--entry-point=main \
--trigger-http \
--allow-unauthenticated \
--set-env-vars FIRESTORE_COLLECTION_NAME=UsersTest,ENVIRONMENT=test

Deploy to Prod Environment

It’s the same steps as above, but with these changes:

  1. The cloud function name (hip-log-bot-cf-test > hip-log-bot-cf)
  2. The top-level Firestore collection (UsersTest > Users)
  3. The Environment variable (local > production)
gcloud functions deploy hip-log-bot-cf \
--gen2 \
--runtime=python311 \
--region=us-central1 \
--source=. \
--entry-point=main \
--trigger-http \
--allow-unauthenticated \
--set-env-vars FIRESTORE_COLLECTION_NAME=Users,ENVIRONMENT=production

Notes

  1. We include the env varFIRESTORE_COLLECTION_NAME to configure the deployed instance with the database-collection (eg a prod vs test one) in HipLogDB::__init__