2
0

🧑‍💻 Rename User ID predefined value to Result ID whic…

This commit is contained in:
Baptiste Arnaud
2024-02-16 11:34:54 +01:00
parent 519f3aa4f9
commit 8d50dc9dfa
8 changed files with 27 additions and 9 deletions

View File

@@ -68,6 +68,7 @@ const Expression = ({
case 'Now': case 'Now':
case 'Tomorrow': case 'Tomorrow':
case 'User ID': case 'User ID':
case 'Result ID':
case 'Moment of the day': case 'Moment of the day':
case 'Environment name': case 'Environment name':
case 'Yesterday': { case 'Yesterday': {

View File

@@ -218,6 +218,7 @@ const SetVariableValue = ({
case 'Random ID': case 'Random ID':
case 'User ID': case 'User ID':
case 'Today': case 'Today':
case 'Result ID':
case 'Empty': case 'Empty':
return null return null
} }

View File

@@ -94,6 +94,10 @@ For example,
[Valid value types](../../variables#valid-value-types) for more information. [Valid value types](../../variables#valid-value-types) for more information.
</Info> </Info>
## Result ID
This will set your variable with the current result ID. The result ID is the ID that corresponds to a row of your [Results](../../../results/overview.mdx) table. It can be considered like a User ID for the currently chatting user.
## Moment of the day ## Moment of the day
It will set your variable with either one of these values based on the user's time of the day: `morning`, `afternoon`, `evening`, `night`. It will set your variable with either one of these values based on the user's time of the day: `morning`, `afternoon`, `evening`, `night`.
@@ -130,21 +134,22 @@ For this you can provide the following custom code:
function getLocation() { function getLocation() {
return new Promise((resolve) => { return new Promise((resolve) => {
navigator.geolocation.getCurrentPosition( navigator.geolocation.getCurrentPosition(
position => resolve(`${position.coords.latitude}, ${position.coords.longitude}`), (position) =>
error => resolve("error"), resolve(`${position.coords.latitude}, ${position.coords.longitude}`),
(error) => resolve('error'),
{ enableHighAccuracy: true, timeout: 5000 } { enableHighAccuracy: true, timeout: 5000 }
); )
}); })
} }
const coords = await getLocation(); const coords = await getLocation()
// Check for error // Check for error
if (coords === "error") { if (coords === 'error') {
return "Unable to get location"; return 'Unable to get location'
} }
return coords; return coords
``` ```
This custom function can only work when it is executed on the client browser so you need to make sure to enable the "Execute on client" option. This custom function can only work when it is executed on the client browser so you need to make sure to enable the "Execute on client" option.

View File

@@ -584,6 +584,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -4978,6 +4979,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -8423,6 +8425,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -16931,6 +16934,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -20443,6 +20447,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -23262,6 +23267,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"

View File

@@ -3651,6 +3651,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"
@@ -7455,6 +7456,7 @@
"Empty", "Empty",
"Environment name", "Environment name",
"User ID", "User ID",
"Result ID",
"Random ID", "Random ID",
"Phone number", "Phone number",
"Contact name" "Contact name"

View File

@@ -116,6 +116,7 @@ const getExpressionToEvaluate =
case 'Random ID': { case 'Random ID': {
return `"${createId()}"` return `"${createId()}"`
} }
case 'Result ID':
case 'User ID': { case 'User ID': {
return state.typebotsQueue[0].resultId ?? `"${createId()}"` return state.typebotsQueue[0].resultId ?? `"${createId()}"`
} }

View File

@@ -6,6 +6,7 @@ export const valueTypes = [
'Append value(s)', 'Append value(s)',
'Environment name', 'Environment name',
'User ID', 'User ID',
'Result ID',
'Now', 'Now',
'Today', 'Today',
'Yesterday', 'Yesterday',
@@ -17,7 +18,7 @@ export const valueTypes = [
'Contact name', 'Contact name',
] as const ] as const
export const hiddenTypes = ['Today'] as const export const hiddenTypes = ['Today', 'User ID'] as const
export const defaultSetVariableOptions = { export const defaultSetVariableOptions = {
type: 'Custom', type: 'Custom',

View File

@@ -17,6 +17,7 @@ const basicSetVariableOptionsSchema = baseOptions.extend({
'Empty', 'Empty',
'Environment name', 'Environment name',
'User ID', 'User ID',
'Result ID',
'Random ID', 'Random ID',
'Phone number', 'Phone number',
'Contact name', 'Contact name',