wbb-mysql
v0.0.1
Published
Use this integration to either save form values into a specified table in a MySQL database, or use values entered to query data.
Downloads
2
Readme
Aims / Intro
The aim of this project is to create a handler
( perhaps called save-row
) that will add a configurable amount of data into a row of a MySQL
database.
The data will come from a combination of values entered by the user, and values provided in the function arguments. ie, dynamic
( from the form ) and static
( from the function arguments );
The function will need configuration arguments for things like database host, username, password etc. A sample of these is below..
host : andyfeltham.me
port : 3306
username : afeltham
password : Nt7cugec
database_name : logicdialog_integration
database_table : names
Start by cloing the repository and getting things running locally. You'll need to run npm i
to install the dependancies, and then npm run watch
in one terminal to build the code. In another terminal run npm start
to start the function. This process will need to be restarted with every change.
Also run ngrok http 8080
to expose a public url that connects to your laptop. You can download ngrok from here -> https://ngrok.com/download
The notes below are a good place to start in terms of things to change. Specifically look at src/handlers/example.ts
and src/handlers/index.ts
.
const requiredParameters = checkRequiredParameters(
[ webhookReq.args?.responseText ] ,
INTEGRATION_BLOCKS.ERROR_BLOCK,
false, false
);
Code like the sample above will check to ensure that the responseText
parameter is set in the function arguments. This is useful for ensuring things like database hostname and password etc are set correctly.
For now i would just use the simple example we've made so far to reply with a confirmation message, but eventually we'd need to expand the configuration so that we had a concept of being able to configure a next
block, or error
block to handle either of these cases. These integrations are intended to be building blocks to be used in lots of scenarios and so the more configurable they are the better.
Good luck!
WBB Sample Public Integration Template
This project is a template for creating new integrations via cloud functions. The files should be modified as follows :
- Update the package.json file
- change the name. Please ensure everything is prefixed with
wbb-
- change the
deploy-dev
anddeploy-prod
tasks. Specifically change thedeploy
option fromwbb-integration-template
to something specific to the function. This again should be prefixed withwbb-
for examplewbb-mailchimp
.
- change the name. Please ensure everything is prefixed with
- Update the README.md, see notes and instructions for the template below.
- Create
src/handlers/my-integration.ts
- create a file to handle the integration, giving it an appropriate name. An example is provided insrc/handlers/example.ts
- Update
src/handlers/index.ts
- update the root file to reference the handlers that you've created.
Various functions exist in the src/util/validation.ts
file that will help validate parameters required, as well as perform string substitution if required.
Development
- run
npm run watch
to start building the code and watching for changes. - In a separate terminal run
npm start
to start the functions framework and make the code accessible via HTTP - Use
ngrok
to make the webserver public, iengrok http 8080
.
Setup
Complete any setup instructions here.
Blocks Provided
Provide a list of the blocks provided as part of this integration. This should be a list of block name, and its description.
Handler Names
The following handler names and their functions are available :
|Handler Name|Purpose| |------------|-------|
Configuration Options
( Provide a list of the configuration options for each of the handlers mentioned above )
Within the function there are a number of options that can be set to configure the behaviour of the integration. The tables below show the settings that are available for each handler.
handler-one
|Property|Required|Description| |--------|--------|-----------|