Skip to content

Create Get a data of a particular flow from BigQuery.md #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
> ### **3 minutes read                                                                                                                         `Beginner`**


## Get Data for a Specific Flow from BigQuery:

- Login to your Google account https://console.cloud.google.com/
- Click on Big Query Tab
- Click on small trangle next to your project ID
- Click on small trangle next to the your BOT number
- Click on any of the table.
- In the right pane clikc on Query Tab in the Split tab
- Write the below query to get the results of a single flow
- **SELECT * FROM `your_dataset.messages` where flow_name = `flow_name` order by inserted_at DESC**

## Extract Data by Flow from BigQuery:

- The following query can be used to extract data by flow.

```sql
WITH extracted_json AS (
SELECT
contact_phone,
contact_name,
JSON_EXTRACT_SCALAR(results, '$.feedback_positive.input') AS feedback_positive,
JSON_EXTRACT_SCALAR(results, '$.result_q1_pos.input') AS result_q1_pos,
JSON_EXTRACT_SCALAR(results, '$.result_q2_pos.input') AS result_q2_pos,
JSON_EXTRACT_SCALAR(results, '$.result_q3_pos.input') AS result_q3_pos
FROM
`your_project.your_dataset.your_table` where uuid = "flow_uuid"
)
SELECT * FROM extracted_json;
```

- All flow results must be added in a similar manner:

`JSON_EXTRACT_SCALAR(results, '$.flow_result.input') AS flow_result,`

- Running the query will generate a table displaying phone numbers, names, and their flow results, which can then be exported as a CSV.