|
| 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( |
| 19 | + projectId, |
| 20 | + transcriptUri = 'gs://cloud-samples-data/ccai/chat_sample.json', |
| 21 | + audioUri = 'gs://cloud-samples-data/ccai/voice_6912.txt' |
| 22 | +) { |
| 23 | + // [START contactcenterinsights_create_conversation_with_ttl] |
| 24 | + /** |
| 25 | + * TODO(developer): Uncomment these variables before running the sample. |
| 26 | + */ |
| 27 | + // const projectId = 'my_project_id'; |
| 28 | + // const transcriptUri = 'gs://cloud-samples-data/ccai/chat_sample.json'; |
| 29 | + // const audioUri = 'gs://cloud-samples-data/ccai/voice_6912.txt'; |
| 30 | + |
| 31 | + // Imports the Contact Center Insights client. |
| 32 | + const { |
| 33 | + ContactCenterInsightsClient, |
| 34 | + } = require('@google-cloud/contact-center-insights'); |
| 35 | + |
| 36 | + // Instantiates a client. |
| 37 | + const client = new ContactCenterInsightsClient(); |
| 38 | + |
| 39 | + async function createConversationWithTtl() { |
| 40 | + const [conversation] = await client.createConversation({ |
| 41 | + parent: client.locationPath(projectId, 'us-central1'), |
| 42 | + conversation: { |
| 43 | + dataSource: { |
| 44 | + gcsSource: { |
| 45 | + transcriptUri: transcriptUri, |
| 46 | + audioUri: audioUri, |
| 47 | + }, |
| 48 | + }, |
| 49 | + medium: 'CHAT', |
| 50 | + ttl: { |
| 51 | + seconds: 86400, |
| 52 | + }, |
| 53 | + }, |
| 54 | + }); |
| 55 | + console.info(`Created ${conversation.name}`); |
| 56 | + } |
| 57 | + createConversationWithTtl(); |
| 58 | + // [END contactcenterinsights_create_conversation_with_ttl] |
| 59 | +} |
| 60 | + |
| 61 | +process.on('unhandledRejection', err => { |
| 62 | + console.error(err.message); |
| 63 | + process.exitCode = 1; |
| 64 | +}); |
| 65 | +main(...process.argv.slice(2)); |
0 commit comments