Skip to content

A Stackchat platform Cloud Function example using TypeScript and Webpack

License

Notifications You must be signed in to change notification settings

stackchat-ai/cloud-function-packaging-example

Repository files navigation

Cloud Function Example with TypeScript and Webpack

This repository provides a sample Cloud Function for the Stackchat Platform which illustrates:

  • calling a 3rd-party API
  • dynamically generating a carousel
  • a basic unit test
  • using TypeScript instead of vanilla JS
  • bundling additional dependencies

Developer Set-up

Just clone this repo, install the dependencies (yarn or npm i) and build (yarn run build or npm run build). This will produce a dist/cloud-functions.js file which can be uploaded via the Cloud Functions section of the Stackchat dashboard for your bot.

Implementation Notes

  1. request-promise is used here to illustrate packaging a 3rd-party dependency. For making API calls generally, node-fetch is already available (as fetch) to your code at runtime without requiring any additional packaging or import statements.

  2. The "externals" section of the webpack configuration will omit bundling of the dc and fetch dependencies that are available at runtime. This can be removed if you want to provide and use a different version.

About

A Stackchat platform Cloud Function example using TypeScript and Webpack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published