2 levels of variables

(Alexey Klepov) #1

Hi guys.
Please help me with that problem.
I’ve made a sql query. Later I can use the result of it like this: {{run_a_query_new_lead.result__rows__0__status_name}}
But if I have several lines in answer and I want to use all of them?

I tried to use attributes in a small cycle: {{run_a_query_new_lead.result__rows__{{get_an_attribute.value}}__status_name}}
But this is not works. Is there any solution for me problem?

(Alexey Klepov) #2

@johnjackson may be you can help me.

I made next step

In code block I’ve generated this string:
Result
{
“name”: “{{run_a_query_new_lead.result__ro
ws__0__responsible_user_name}}”
}

then, I put a result in field in Google Sheets - Add a Row like this:

{{code_insert_number.result__name}}

But it not works.
I suggest this block is treated as text and not as a variable.
Google sheets inserts a row with text
{{run_a_query_new_lead.result__rows__0__responsible_user_name}}
instead of
Mark
(for example)

(John Jackson) #3

It does look like the {{run_a_query_new_lead.result__rows__0__responsible_user_name}} is not a known variable. I would focus on that - check that you are referenced exactly the correct property.

If you can post an example of the data format here we can take a look?

(Alexey Klepov) #4

Here some screenshots from flow:
Code block:

Result (in interactions)

Add a row block

Result of add a row block

In the second line I wrote a variable “by hand” and it works fine.

(John Jackson) #5

It’s actually the output before here we need to see (the output from run_a_query_new_lead). The output of the code action shouldn’t contain that variable, that should have been replaced by a real value at that point.

(Alexey Klepov) #6

John, here is a result of query if I understood correctly your words

Result
{
“rows”: [
{
“responsible_user_name”: “Яна Чаплыгина”,
“status_name”: “Новый клиент”,
“COUNT()": 4,
“sort”: 10
},
{
“responsible_user_name”: “Юрий Шустанов”,
“status_name”: “Новый клиент”,
"COUNT(
)”: 2,
“sort”: 10
}
],

My goal is to fill in the google sheet with that data. And I don’t have solution for it now. I want to make a universal script, which does not depend on the number of rows in the table. Because one time it could be 2 another time 9.

(Karen Barker) #7

Hi Alexey,

Thanks for sending this across.

Unfortunately it won’t be possible to handle this in the way your code block currently does.

You’ll need to pass the data set into the code block as an Input which uses the magic repeat functionality {{ output * }}.

In your code you’ll then need to split this on the new line to create an array. You can then resolve the nth item of the array and this will give the actual value as the output of the code service so you can then go on to use this in the later search.

I hope this helps. :slight_smile:

(Alexey Klepov) #8

Thanks Karen, you gave me direction for the solutin.
But now I have another problem.
In my row I need to feel google sheets rows with data. I can only fill one row at a time. I do it with “go to label” statements. And I ran into a limitation: only 20 times in one flow. Can I raise limit to at least 50 times? Or may be there are in plans implement filling more than 1 row at a time in googlesheets?

(Daniel Beckett) #9

Hi @mr.Klepoff

I’m sorry but at the moment there’s no way to increase the limit for GoTo Labels. As a workaround you could look into triggering the flow again and passing in Metadata so that the flow can continue from where you left off.

In regards to adding the ability to add more than one row at a time I’ll pass this idea over to our development team for consideration with future updates.

Thanks,
Dan

(Alexey Klepov) #10

OK, thanks, I’ll try.

(Alexey Klepov) #11

@DanielBeckett, can you say, can I call a flow by itself with “trigger a flow”?

(Daniel Beckett) #12

You can use the Trigger a Flow action to trigger any New Message or Flow ‘new trigger’.

(Alexey Klepov) #13

Daniel, please I need help!!! I don’t understand!!!
Here is a start of my flow.

When flow is started I try to set an attribute, but I can’t do it.

Here is “inside” of set an attribute section

And here is a message of a mistake:


What’s wrong with my flow?

I encotered this time of mistakes before, and solved it by changing response path. But in this case I tryed many variants and they not work!!!

(Karen Barker) #14

Hi there,

Rather than specifying a specific response path if you click the “use default response path” link then this will allow the bot to use the same response path as the trigger automatically and should solve the problem :slight_smile:

(Alexey Klepov) #15

Hello again.

Here is how things going with default respose path:

This is a bug? What can I do with it?

(Karen Barker) #16

Hi,

What is the trigger of the flow you are using the new flow trigger in? It looks like the original flow doesn’t have a response path to pass on? What does the bot do? Do you need the attribute stored against a specific user or can it simply be a generically stored value?

(Alexey Klepov) #17

It can be generically stored value. First flow triggered by a hook. Then first flow triggers the second one and transfers some metadata. In that case I don’t use any conversation with user, only google sheets

(Karen Barker) #18

Ah…that explains why you have no response path - response paths are only available when you’re in a conversation with a user and aren’t passed on flows which are triggered with a 3rd party application. For attributes you can store values on a generic response path. For example in the response path field you could just use a generic name such as “Delete” or perhaps your email address etc. Any value is acceptable in this field for storing an attribute - if you need to access the attribute in a different flow just use the same response path to get this attribute from as well. :slight_smile:

(Alexey Klepov) #19

Thank you Karen. It works!!