- A react native frontend application uses this: https://expo.io/@adennyh/cobbie-frontend
We were exploring a startup idea to assist HR on figuring out the well-being of their employees. The idea is to create a chatbot-buddy that personally interacts with each of the employees, continously asking some short of surveys to monitor their mental well-being. This was a proof-of-concept we build in order to gauge potential investor's interest.
This code base powers the backend of the chatbot. It uses finite-state-machine described in a typescript definition (src/data/sets.ts) that can easily be modified to program the bot, such as to modify the text prompt or the multiple-choice input.
The frontend React Native counterpart can be found here: https://github.com/dharijanto/cobbie-chatbot-reactnative-frontend
- Response:
{
messages: [
'Hi there, nice to meet you!',
'My name is Cobbie, your personal assistant :)'
],
responses: [
{ type: 'button', text: 'Nice to meet you too, Cobbie!'}
]
}
- Body
{
index: 0,
data: {
text: 'This is filled only if the response is of type free-text'
}
}
Because this was just a proof-of-concept, to reduce the development effort we leverage on Google Sheet to process the employee survey. A partner of mine focused on writing google sheet formula to process rows that are inserted by this backend via Sheet's API. After Sheet has finished processing the result, this backend retrieves it using another API call.
- Go to Google APIs console https://console.developers.google.com/
- Create service account keys, with role as editor
- Download JSON key
- Copy email client, and share the spreadsheet with that email client
- Now we can use Google console's web interface to do testing
- Follow this to enable auth from NodeJS (through OAuth) https://developers.google.com/sheets/api/quickstart/nodejs#step_3_set_up_the_sample
- Insert to table
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
- Spreadsheet ID: Look at the sheet's URL, just after /id/
- Range: A1 Notation (i.e. "Sheet1!A1:Z1000") -> this is used to figure out where the table is
- insertDataOption: 'INSERT_ROWS'
- Value Input Option: "USER ENTERED"
- Request body:
{ "values": [ [ "Denny", "Harijanto", 28, "University of Washington" ] ] }
- Response body:
{ "spreadsheetId": "1o4zVGBpvjRW9FE2adhYw5HKRefGaYf_igzPZxpyZyGw", "tableRange": "Sheet1!A1:D1", "updates": { "spreadsheetId": "1o4zVGBpvjRW9FE2adhYw5HKRefGaYf_igzPZxpyZyGw", "updatedRange": "Sheet1!A2:D2", "updatedRows": 1, "updatedColumns": 4, "updatedCells": 4 } }