Skip to content

Commit bef7132

Browse files
authored
chore(contact-center): migrate code from googleapis/nodejs-contact-center-insights (#2817)
- feat: initial generation of templated files - feat: add initial samples (#2) - chore(deps): update dependency mocha to v9 (#3) - chore: release 1.0.0 (#1) - chore: release 1.0.1 (#12) - chore: release 1.0.2 (#18) - chore: release 1.1.0 (#21) - chore: release 1.2.0 (#26) - chore: release 1.2.1 (#29) - chore: release 1.3.0 (#36) - chore: release 1.4.0 (#40) - samples: get operation (#52) - samples: create conversation, create analysis, export data to BigQuery (#34) - samples: enable pubsub notifications (#48) - samples: modify TTL in create conversation with TTL sample (#57) - samples: create topic model (#49) - chore: release 1.5.0 (#58) - samples: set project-level TTL (#51) - samples: create custom highlights (#53) - chore: release 1.6.0 (#65) - chore: release 1.7.0 (#69) - chore: release 1.8.0 (#75) - chore: release 1.9.0 (#81) - chore(main): release 1.11.0 (#107) - build: add retries for flaky test (#109) - build!: update library to use Node 12 (#122) - chore(main): release 2.0.0 (#124) - fix(deps): update dependency @google-cloud/bigquery to v6 (#127) - fix(deps): update dependency @google-cloud/pubsub to v3 (#126) - chore(main): release 2.0.1 (#129) - chore(main): release 2.1.0 (#134) - chore(main): release 2.1.1 (#139) - chore(deps): update dependency uuid to v9 (#142)
1 parent e35f9de commit bef7132

24 files changed

+1362
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: contact-center-insights
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'contact-center-insights/**'
8+
pull_request:
9+
paths:
10+
- 'contact-center-insights/**'
11+
pull_request_target:
12+
types: [labeled]
13+
schedule:
14+
- cron: '0 0 * * 0'
15+
jobs:
16+
test:
17+
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 60
20+
permissions:
21+
contents: 'write'
22+
pull-requests: 'write'
23+
id-token: 'write'
24+
steps:
25+
- uses: actions/[email protected]
26+
with:
27+
ref: ${{github.event.pull_request.head.ref}}
28+
repository: ${{github.event.pull_request.head.repo.full_name}}
29+
- uses: 'google-github-actions/[email protected]'
30+
with:
31+
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
32+
service_account: '[email protected]'
33+
create_credentials_file: 'true'
34+
access_token_lifetime: 600s
35+
- uses: actions/[email protected]
36+
with:
37+
node-version: 16
38+
- run: npm install
39+
working-directory: contact-center-insights
40+
- run: npm test
41+
working-directory: contact-center-insights
42+
env:
43+
MOCHA_REPORTER_SUITENAME: contact_center_insights
44+
MOCHA_REPORTER_OUTPUT: contact_center_insights_sponge_log.xml
45+
MOCHA_REPORTER: xunit
46+
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
47+
uses: actions/github-script@v6
48+
with:
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
script: |
51+
try {
52+
await github.rest.issues.removeLabel({
53+
name: 'actions:force-run',
54+
owner: 'GoogleCloudPlatform',
55+
repo: 'nodejs-docs-samples',
56+
issue_number: context.payload.pull_request.number
57+
});
58+
} catch (e) {
59+
if (!e.message.includes('Label does not exist')) {
60+
throw e;
61+
}
62+
}
63+
- if: ${{ github.event_name == 'schedule'}}
64+
run: |
65+
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
66+
chmod +x ./flakybot
67+
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

.github/workflows/workflows.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@
4646
"datacatalog/cloud-client",
4747
"datacatalog/quickstart",
4848
"datastore/functions",
49-
"talent"
49+
"talent",
50+
"contact-center-insights"
5051
]

CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ composer @leahecole @sofisl @GoogleCloudPlatform/nodejs-samples-reviewers
3535
healthcare @noerog @GoogleCloudPlatform/nodejs-samples-reviewers
3636
monitoring/opencensus @GoogleCloudPlatform/nodejs-samples-reviewers
3737

38+
# Data & AI
39+
contact-center-insights @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
40+
talent @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-reviewers
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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(conversationName) {
19+
// [START contactcenterinsights_create_analysis]
20+
/**
21+
* TODO(developer): Uncomment this variable before running the sample.
22+
*/
23+
// const conversationName = 'projects/my_project_id/locations/us-central1/conversations/my_conversation_id';
24+
25+
// Imports the Contact Center Insights client.
26+
const {
27+
ContactCenterInsightsClient,
28+
} = require('@google-cloud/contact-center-insights');
29+
30+
// Instantiates a client.
31+
const client = new ContactCenterInsightsClient();
32+
33+
async function createAnalysis() {
34+
const [operation] = await client.createAnalysis({
35+
parent: conversationName,
36+
});
37+
38+
// Wait for the operation to complete.
39+
const [analysis] = await operation.promise();
40+
console.info(`Created ${analysis.name}`);
41+
}
42+
createAnalysis();
43+
// [END contactcenterinsights_create_analysis]
44+
}
45+
46+
process.on('unhandledRejection', err => {
47+
console.error(err.message);
48+
process.exitCode = 1;
49+
});
50+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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]
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 createConversation() {
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+
},
51+
});
52+
console.info(`Created ${conversation.name}`);
53+
}
54+
createConversation();
55+
// [END contactcenterinsights_create_conversation]
56+
}
57+
58+
process.on('unhandledRejection', err => {
59+
console.error(err.message);
60+
process.exitCode = 1;
61+
});
62+
main(...process.argv.slice(2));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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) {
19+
// [START contactcenterinsights_create_issue_model]
20+
/**
21+
* TODO(developer): Uncomment this variable before running the sample.
22+
*/
23+
// const projectId = 'my_project_id';
24+
25+
// Imports the Contact Center Insights client.
26+
const {
27+
ContactCenterInsightsClient,
28+
} = require('@google-cloud/contact-center-insights');
29+
30+
// Instantiates a client.
31+
const client = new ContactCenterInsightsClient();
32+
33+
async function createIssueModel() {
34+
const [operation] = await client.createIssueModel({
35+
parent: client.locationPath(projectId, 'us-central1'),
36+
issueModel: {
37+
displayName: 'my-model',
38+
inputDataConfig: {
39+
filter: 'medium="CHAT"',
40+
},
41+
},
42+
});
43+
44+
// Wait for the operation to complete.
45+
const [issueModel] = await operation.promise();
46+
console.info(`Created ${issueModel.name}`);
47+
}
48+
createIssueModel();
49+
// [END contactcenterinsights_create_issue_model]
50+
}
51+
52+
process.on('unhandledRejection', err => {
53+
console.error(err.message);
54+
process.exitCode = 1;
55+
});
56+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)