Skip to content

Commit 9d7b1dd

Browse files
author
dvonthenen
committed
Redaction Example
1 parent 80fb5a8 commit 9d7b1dd

File tree

14 files changed

+111
-30
lines changed

14 files changed

+111
-30
lines changed

examples/node/async-upload/action-items/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process ActionItems for the audio file
2424
*/
25-
var actionItems = await async.ActionItems(token, result.conversationId);
25+
var actionItems = await async.ActionItems(token, result.conversationId, "none");
2626
var output = JSON.parse(actionItems);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/analytics/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Analytics for the audio file
2424
*/
25-
var analytics = await async.Analytics(token, result.conversationId);
25+
var analytics = await async.Analytics(token, result.conversationId, "none");
2626
var output = JSON.parse(analytics);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/entities/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Entites for the audio file
2424
*/
25-
var entities = await async.Entities(token, result.conversationId);
25+
var entities = await async.Entities(token, result.conversationId, "none");
2626
var output = JSON.parse(entities);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/follow-ups/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process FollowUps for the audio file
2424
*/
25-
var followUps = await async.FollowUps(token, result.conversationId);
25+
var followUps = await async.FollowUps(token, result.conversationId, "none");
2626
var output = JSON.parse(followUps);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/messages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Messages for the audio file
2424
*/
25-
var messages = await async.Messages(token, result.conversationId);
25+
var messages = await async.Messages(token, result.conversationId, "none");
2626
var output = JSON.parse(messages);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/questions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Questions for the audio file
2424
*/
25-
var questions = await async.Questions(token, result.conversationId);
25+
var questions = await async.Questions(token, result.conversationId, "none");
2626
var output = JSON.parse(questions);
2727
console.log(util.inspect(output, false, null, true));
2828
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Using the Redaction Async API
2+
3+
This is a simple main-style sample application using Symbl's Async API. This application will post an audio file to the platform and obtain the Message with Redacted results when they become available.
4+
5+
## Getting started
6+
7+
Open `.env` file and add your APP_ID, APP_SECRET, SUMMARY_EMAIL. You can get APP_ID and APP_SECRET from [https://platform.symbl.ai](https://platform.symbl.ai)
8+
9+
Most of the heavy lifting is done in the `common` library which you can read about its plumbing [here](../../common/README.md).
10+
11+
## Async Conversation Processing
12+
13+
Obtaining intelligence on Messages using the Async API is pretty straight forward, the steps are:
14+
15+
1. Login
16+
2. Post the audio file and wait for the Symbl platform to process it
17+
3. Retrieve the Messages with Redacted Results
18+
19+
```
20+
async function main() {
21+
/*
22+
Login and get token
23+
*/
24+
var token = await common.Login();
25+
26+
/*
27+
Post the audio file to the Symbl platform
28+
*/
29+
var result = await post.Post(token, "All_I_Really_Want.mp3");
30+
31+
/*
32+
Process Messages for the audio file
33+
*/
34+
var messages = await intelligence.Messages(token, result.conversationId, "exclude=[\"LOCATION_STATE\""]&redact=true");
35+
output = JSON.parse(messages);
36+
console.log(output);
37+
}
38+
39+
main();
40+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2022 Symbl.ai SDK contributors. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
require('dotenv').config()
5+
const util = require('util')
6+
7+
const common = require('../../common/common.js');
8+
const post = require('../../common/post-file.js');
9+
const async = require('../../common/async.js');
10+
11+
async function main() {
12+
/*
13+
Login and get token
14+
*/
15+
var token = await common.Login();
16+
17+
/*
18+
Post the audio file to the Symbl platform
19+
*/
20+
var result = await post.Post(token, process.env.FILENAME);
21+
22+
/*
23+
Process Messages for the audio file
24+
*/
25+
var messages = await async.Messages(token, result.conversationId, "exclude=[\"PERSON_NAME\"]&redact=true");
26+
var output = JSON.parse(messages);
27+
console.log(util.inspect(output, false, null, true));
28+
}
29+
30+
main();

examples/node/async-upload/summary/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Summary for the audio file
2424
*/
25-
var summary = await async.Summary(token, result.conversationId);
25+
var summary = await async.Summary(token, result.conversationId, "none");
2626
var output = JSON.parse(summary);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/topics/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function main() {
2222
/*
2323
Process Topics for the audio file
2424
*/
25-
var topics = await async.Topics(token, result.conversationId);
25+
var topics = await async.Topics(token, result.conversationId, "none");
2626
var output = JSON.parse(topics);
2727
console.log(util.inspect(output, false, null, true));
2828
}

examples/node/async-upload/trackers/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function main() {
1919
/*
2020
Process Trackers for the audio file
2121
*/
22-
var trackers = await async.Trackers(token, result.conversationId);
22+
var trackers = await async.Trackers(token, result.conversationId, "none");
2323
var output = JSON.parse(trackers);
2424
console.log(util.inspect(output, false, null, true));
2525
}

examples/node/common/async.js

+27-20
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@ require('dotenv').config()
55
var common = require('./common.js');
66
const fetch = require('node-fetch');
77

8-
exports.Topics = async function(token, conversationId) {
9-
return processIntelligence(token, "topics", conversationId);
8+
exports.Topics = async function(token, conversationId, params) {
9+
return processIntelligence(token, "topics", conversationId, params);
1010
}
1111

12-
exports.Questions = async function(token, conversationId) {
13-
return processIntelligence(token, "questions", conversationId);
12+
exports.Questions = async function(token, conversationId, params) {
13+
return processIntelligence(token, "questions", conversationId, params);
1414
}
1515

16-
exports.FollowUps = async function(token, conversationId) {
17-
return processIntelligence(token, "follow-ups", conversationId);
16+
exports.FollowUps = async function(token, conversationId, params) {
17+
return processIntelligence(token, "follow-ups", conversationId, params);
1818
}
1919

20-
exports.Entities = async function(token, conversationId) {
21-
return processIntelligence(token, "entities", conversationId);
20+
exports.Entities = async function(token, conversationId, params) {
21+
return processIntelligence(token, "entities", conversationId, params);
2222
}
2323

24-
exports.ActionItems = async function(token, conversationId) {
25-
return processIntelligence(token, "action-items", conversationId);
24+
exports.ActionItems = async function(token, conversationId, params) {
25+
return processIntelligence(token, "action-items", conversationId, params);
2626
}
2727

28-
exports.Messages = async function(token, conversationId) {
29-
return processIntelligence(token, "messages", conversationId);
28+
exports.Messages = async function(token, conversationId, params) {
29+
return processIntelligence(token, "messages", conversationId, params);
3030
}
3131

32-
exports.Summary = async function(token, conversationId) {
33-
return processIntelligence(token, "summary", conversationId);
32+
exports.Summary = async function(token, conversationId, params) {
33+
return processIntelligence(token, "summary", conversationId, params);
3434
}
3535

36-
exports.Analytics = async function(token, conversationId) {
37-
return processIntelligence(token, "analytics", conversationId);
36+
exports.Analytics = async function(token, conversationId, params) {
37+
return processIntelligence(token, "analytics", conversationId, params);
3838
}
3939

40-
exports.Trackers = async function(token, conversationId) {
41-
return processIntelligence(token, "trackers-detected", conversationId);
40+
exports.Trackers = async function(token, conversationId, params) {
41+
return processIntelligence(token, "trackers-detected", conversationId, params);
4242
}
4343

44-
async function processIntelligence(token, api, conversationId) {
44+
async function processIntelligence(token, api, conversationId, params) {
4545
// console.log("conversationId: " + conversationId);
4646

4747
const header = {
@@ -50,7 +50,14 @@ async function processIntelligence(token, api, conversationId) {
5050
"Connection": "keep-alive",
5151
};
5252

53-
var uri = `https://api.symbl.ai/v1/conversations/${conversationId}/${api}?parentRefs=true&sentiment=true`;
53+
if (params == "all") {
54+
params = "parentRefs=true&sentiment=true"
55+
}
56+
57+
var uri = `https://api.symbl.ai/v1/conversations/${conversationId}/${api}?${params}`;
58+
if (params == "none" || params == "") {
59+
uri = `https://api.symbl.ai/v1/conversations/${conversationId}/${api}`
60+
}
5461
var response = await common.Query(uri, "GET", header, null);
5562
var text = await response.text();
5663
// console.log("response: " + response);

phoneNumber.mp3

77.3 KB
Binary file not shown.

run-example.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ if [[ -z "${URL}" ]]; then
136136
URL="https://symbltestdata.s3.us-east-2.amazonaws.com/newPhonecall.mp3"
137137
fi
138138
if [[ -z "${FILENAME}" ]]; then
139-
FILENAME="newPhonecall.mp3"
139+
if [[ "${EXAMPLE_NAME}" == "redaction" ]]; then
140+
FILENAME="phoneNumber.mp3"
141+
else
142+
FILENAME="newPhonecall.mp3"
143+
fi
140144
fi
141145

142146
if [[ -z "${EXAMPLE_NAME}" ]]; then

0 commit comments

Comments
 (0)