Skip to content

Instantly share code, notes, and snippets.

@thatguynef
Last active April 14, 2023 07:06
Show Gist options
  • Save thatguynef/dcbe807e4c54a0b2d3488a6a904d8b9b to your computer and use it in GitHub Desktop.
Save thatguynef/dcbe807e4c54a0b2d3488a6a904d8b9b to your computer and use it in GitHub Desktop.
Google Sheets and Typebot Decision Tree Demo
{"id":"clgg0d94w000cif0fwpkofrpl","version":"3","createdAt":"2023-04-14T03:47:20.576Z","updatedAt":"2023-04-14T06:41:43.451Z","icon":"🌲","name":"Decision Tree Demo","folderId":"clfhg550l0009m908jsmr2fv4","groups":[{"id":"imwuej91htznt2m7kcl4t0d9","title":"Start","blocks":[{"id":"gorwk3vrjb1wahr39ixmg5ks","type":"start","label":"Start","groupId":"imwuej91htznt2m7kcl4t0d9"}],"graphCoordinates":{"x":0,"y":0}},{"id":"az78lk8hr9fwmrrpvwtcj74p","title":"Group #1","blocks":[{"id":"d0nrtwpuxkk39kvsnh3wtu1d","type":"Webhook","groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"isCustomBody":false,"isAdvancedConfig":true,"variablesForTest":[],"responseVariableMapping":[{"id":"faiay65pf70bha8t6j380ukl","bodyPath":"data","variableId":"vge7kig6f1gd6ickohwdrwpzn"}]},"webhookId":"foqsepk9ybi7kma11zjf457b"},{"id":"jh2de3632hn0j6tadb90h875","type":"Set variable","groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"isCode":true,"variableId":"vjlfkhyqsvr49a4tb0227j7ko","expressionToEvaluate":"const json = JSON.parse({{data}});\n\nconst properties = new Set();\n\nfor (let i = 1; i < json.values.length; i++) {\n const row = json.values[i];\n if (row[0] !== \"\" && row[0] !== undefined) {\n properties.add(row[0]);\n }\n}\n\nreturn [...properties]; // Output: [\"Land\", \"Building\", \"Shares\"]\n"}},{"id":"sqki8kpt8dk6cnkcsaaamgh2","type":"choice input","items":[{"id":"npv92ztj5l1pin00bdd8i65x","type":0,"blockId":"sqki8kpt8dk6cnkcsaaamgh2","content":"Click to edit"}],"groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"variableId":"vkf2uizfb0tskwg7yxeu9mare","buttonLabel":"Send","isMultipleChoice":false,"dynamicVariableId":"vjlfkhyqsvr49a4tb0227j7ko"}},{"id":"xt432vwrvopuejb7nlqoflt8","type":"Set variable","groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"isCode":true,"variableId":"vy72dxe9n446efnpwdoadcr09","expressionToEvaluate":"const json = JSON.parse({{data}});\n\nconst landLocations = [];\n\nfor (let i = 1; i < json.values.length; i++) {\n const row = json.values[i];\n if (row[0] === {{selected_property}}) {\n landLocations.push(row[1]);\n }\n}\n\nreturn landLocations; // Output: [\"Rural \", \"Urban\"]\n"}},{"id":"z8omq2r20we0zn5qp03lirjq","type":"choice input","items":[{"id":"uqw3v0qgh02wohz7gvdsp0ot","type":0,"blockId":"z8omq2r20we0zn5qp03lirjq","content":"Click to edit"}],"groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"variableId":"vzp79acaa3hb43na77o9x35yo","buttonLabel":"Send","isMultipleChoice":false,"dynamicVariableId":"vy72dxe9n446efnpwdoadcr09"}},{"id":"klgtu6lbklzvwx77p1j107jf","type":"Set variable","groupId":"az78lk8hr9fwmrrpvwtcj74p","options":{"isCode":true,"variableId":"vy4bc9zq6qkf2s7m02qckhsuh","expressionToEvaluate":"const json = JSON.parse({{data}});\n\nlet ruralLandAnswer = \"\";\n\nfor (let i = 1; i < json.values.length; i++) {\n const row = json.values[i];\n if (row[0] === {{selected_property}} && row[1] === {{selected_location}}) {\n ruralLandAnswer = row[2];\n break;\n }\n}\n\nreturn ruralLandAnswer; // Output: \"Land in rural exempt\"\n\n\n"}},{"id":"h5l09il5mh4gl3kfap97ygiy","type":"text","content":{"richText":[{"type":"p","children":[{"text":"{{answers}}"}]}]},"groupId":"az78lk8hr9fwmrrpvwtcj74p"}],"graphCoordinates":{"x":409.87866210937506,"y":0.3138427734375}}],"variables":[{"id":"vge7kig6f1gd6ickohwdrwpzn","name":"data"},{"id":"vzgo1bepho81fbts6nn48ehwa","name":"json"},{"id":"vjlfkhyqsvr49a4tb0227j7ko","name":"properties"},{"id":"vkf2uizfb0tskwg7yxeu9mare","name":"selected_property"},{"id":"vy72dxe9n446efnpwdoadcr09","name":"locations"},{"id":"vzp79acaa3hb43na77o9x35yo","name":"selected_location"},{"id":"vy4bc9zq6qkf2s7m02qckhsuh","name":"answers"}],"edges":[],"theme":{"chat":{"inputs":{"color":"#303235","backgroundColor":"#FFFFFF","placeholderColor":"#9095A0"},"buttons":{"color":"#FFFFFF","backgroundColor":"#0042DA"},"hostAvatar":{"url":"https://lh3.googleusercontent.com/a-/AOh14GgpQRAIjvQpPbbRvSDkXHHpcSIzS8_4oIgOduAz2w=s96-c","isEnabled":true},"hostBubbles":{"color":"#303235","backgroundColor":"#F7F8FF"},"guestBubbles":{"color":"#FFFFFF","backgroundColor":"#FF8E21"}},"general":{"font":"Open Sans","background":{"type":"Color","content":"#ffffff"}}},"selectedThemeTemplateId":null,"settings":{"general":{"isBrandingEnabled":false,"isInputPrefillEnabled":true,"isHideQueryParamsEnabled":true,"isNewResultOnRefreshEnabled":true},"metadata":{"description":"Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form."},"typingEmulation":{"speed":300,"enabled":true,"maxDelay":1.5}},"publicId":null,"customDomain":null,"workspaceId":"cl364qm9i330628gcp0iqukihk","resultsTablePreferences":null,"isArchived":false,"isClosed":false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment