diff --git a/docs/3. Product Features/09. Reporting & Dashboard/Get a data of a particular flow from BigQuery.md b/docs/3. Product Features/09. Reporting & Dashboard/Get a data of a particular flow from BigQuery.md new file mode 100644 index 000000000..f09ee502b --- /dev/null +++ b/docs/3. Product Features/09. Reporting & Dashboard/Get a data of a particular flow from BigQuery.md @@ -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.