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 'Tomorrow':
case 'User ID':
case 'Result ID':
case 'Moment of the day':
case 'Environment name':
case 'Yesterday': {

View File

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

View File

@ -94,6 +94,10 @@ For example,
[Valid value types](../../variables#valid-value-types) for more information.
</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
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() {
return new Promise((resolve) => {
navigator.geolocation.getCurrentPosition(
position => resolve(`${position.coords.latitude}, ${position.coords.longitude}`),
error => resolve("error"),
(position) =>
resolve(`${position.coords.latitude}, ${position.coords.longitude}`),
(error) => resolve('error'),
{ enableHighAccuracy: true, timeout: 5000 }
);
});
)
})
}
const coords = await getLocation();
const coords = await getLocation()
// Check for error
if (coords === "error") {
return "Unable to get location";
if (coords === 'error') {
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.

View File

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

View File

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

View File

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

View File

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

View File

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