|
| 1 | +// Copyright 2021 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | + |
| 16 | +'use strict'; |
| 17 | + |
| 18 | +function main(projectId, bigqueryProjectId, bigqueryDataset, bigqueryTable) { |
| 19 | + // [START contactcenterinsights_export_to_bigquery] |
| 20 | + /** |
| 21 | + * TODO(developer): Uncomment these variables before running the sample. |
| 22 | + */ |
| 23 | + // const projectId = 'my_project_id'; |
| 24 | + // const bigqueryProjectId = 'my_bigquery_project_id'; |
| 25 | + // const bigqueryDataset = 'my_bigquery_dataset'; |
| 26 | + // const bigqueryTable = 'my_bigquery_table'; |
| 27 | + |
| 28 | + // Imports the Contact Center Insights client. |
| 29 | + const { |
| 30 | + ContactCenterInsightsClient, |
| 31 | + } = require('@google-cloud/contact-center-insights'); |
| 32 | + |
| 33 | + // Instantiates a client. |
| 34 | + const client = new ContactCenterInsightsClient(); |
| 35 | + |
| 36 | + async function exportToBigquery() { |
| 37 | + const [operation] = await client.exportInsightsData({ |
| 38 | + parent: client.locationPath(projectId, 'us-central1'), |
| 39 | + bigQueryDestination: { |
| 40 | + projectId: bigqueryProjectId, |
| 41 | + dataset: bigqueryDataset, |
| 42 | + table: bigqueryTable, |
| 43 | + }, |
| 44 | + filter: 'agent_id="007"', |
| 45 | + }); |
| 46 | + |
| 47 | + // Wait for the operation to complete. |
| 48 | + await operation.promise(); |
| 49 | + console.info('Exported data to BigQuery'); |
| 50 | + } |
| 51 | + exportToBigquery(); |
| 52 | + // [END contactcenterinsights_export_to_bigquery] |
| 53 | +} |
| 54 | + |
| 55 | +process.on('unhandledRejection', err => { |
| 56 | + console.error(err.message); |
| 57 | + process.exitCode = 1; |
| 58 | +}); |
| 59 | +main(...process.argv.slice(2)); |
0 commit comments