Skip to content

Commit b733d83

Browse files
authored
Twilio - Get Transcript & update Get Call (#14700)
* get-transcripts & updated get-call * versions
1 parent d65068e commit b733d83

File tree

24 files changed

+135
-25
lines changed

24 files changed

+135
-25
lines changed

components/twilio/actions/check-verification-token/check-verification-token.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "Check Verification Token",
77
description: "Check if user-provided token is correct. [See the documentation](https://www.twilio.com/docs/verify/api)",
88
type: "action",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
props: {
1111
app,
1212
serviceSid: {

components/twilio/actions/create-verification-service/create-verification-service.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Create Verification Service",
66
description: "Create a verification service for sending SMS verifications. [See the documentation](https://www.twilio.com/docs/verify/api/service#create-a-verification-service)",
77
type: "action",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
props: {
1010
twilio,
1111
friendlyName: {

components/twilio/actions/delete-call/delete-call.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "twilio-delete-call",
55
name: "Delete Call",
66
description: "Remove a call record from your account. [See the documentation](https://www.twilio.com/docs/voice/api/call-resource#delete-a-call-resource)",
7-
version: "0.1.3",
7+
version: "0.1.4",
88
type: "action",
99
props: {
1010
twilio,

components/twilio/actions/delete-message/delete-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "twilio-delete-message",
55
name: "Delete Message",
66
description: "Delete a message record from your account. [See the documentation](https://www.twilio.com/docs/sms/api/message-resource#delete-a-message-resource)",
7-
version: "0.1.3",
7+
version: "0.1.4",
88
type: "action",
99
props: {
1010
twilio,

components/twilio/actions/download-recording-media/download-recording-media.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "twilio-download-recording-media",
99
name: "Download Recording Media",
1010
description: "Download a recording media file. [See the documentation](https://www.twilio.com/docs/voice/api/recording#fetch-a-recording-media-file)",
11-
version: "0.1.5",
11+
version: "0.1.6",
1212
type: "action",
1313
props: {
1414
twilio,

components/twilio/actions/get-call/get-call.mjs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "twilio-get-call",
66
name: "Get Call",
77
description: "Return call resource of an individual call. [See the documentation](https://www.twilio.com/docs/voice/api/call-resource#fetch-a-call-resource)",
8-
version: "0.1.3",
8+
version: "0.1.4",
99
type: "action",
1010
props: {
1111
twilio,
@@ -16,9 +16,60 @@ export default {
1616
],
1717
optional: false,
1818
},
19+
includeTranscripts: {
20+
type: "boolean",
21+
label: "Include Transcripts",
22+
description: "Set to `true` to include recording transcript(s) if available",
23+
optional: true,
24+
},
25+
},
26+
methods: {
27+
async getTranscripts(callSid) {
28+
const transcripts = [];
29+
const recordings = await this.twilio.listRecordings({
30+
callSid,
31+
});
32+
for (const recording of recordings) {
33+
const recordingTranscripts = await this.getRecordingTranscripts(recording.sid);
34+
if (recordingTranscripts?.length) {
35+
transcripts.push(...recordingTranscripts);
36+
}
37+
}
38+
return transcripts;
39+
},
40+
async getRecordingTranscripts(sourceSid) {
41+
const transcripts = await this.twilio.listTranscripts({
42+
sourceSid,
43+
});
44+
const results = [];
45+
for (const transcript of transcripts) {
46+
const {
47+
sentences, transcript: fullTranscript,
48+
} = await this.twilio.getSentences(transcript.sid);
49+
results.push({
50+
...transcript,
51+
_version: undefined,
52+
sentences,
53+
transcript: fullTranscript,
54+
});
55+
}
56+
return results;
57+
},
1958
},
2059
async run({ $ }) {
21-
const resp = await this.twilio.getCall(this.sid);
60+
let resp = await this.twilio.getCall(this.sid);
61+
62+
if (this.includeTranscripts) {
63+
const transcripts = await this.getTranscripts(this.sid);
64+
if (transcripts?.length) {
65+
resp = {
66+
...resp,
67+
_version: undefined,
68+
transcripts,
69+
};
70+
}
71+
}
72+
2273
$.export("$summary", `Successfully fetched the call, "${callToString(resp)}"`);
2374
return resp;
2475
},

components/twilio/actions/get-message/get-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "twilio-get-message",
66
name: "Get Message",
77
description: "Return details of a message. [See the documentation](https://www.twilio.com/docs/sms/api/message-resource#fetch-a-message-resource)",
8-
version: "0.1.3",
8+
version: "0.1.4",
99
type: "action",
1010
props: {
1111
twilio,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import twilio from "../../twilio.app.mjs";
2+
3+
export default {
4+
key: "twilio-get-transcripts",
5+
name: "Get Transcripts",
6+
description: "Retrieves full transcripts for the specified transcript SIDs. [See the documentation](https://www.twilio.com/docs/voice/intelligence/api/transcript-sentence-resource#get-transcript-sentences)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
twilio,
11+
transcriptSids: {
12+
propDefinition: [
13+
twilio,
14+
"transcriptSids",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const transcripts = [];
20+
for (const sid of this.transcriptSids) {
21+
transcripts.push(await this.twilio.getTranscript(sid));
22+
}
23+
const results = [];
24+
for (const transcript of transcripts) {
25+
const {
26+
sentences, transcript: fullTranscript,
27+
} = await this.twilio.getSentences(transcript.sid);
28+
results.push({
29+
...transcript,
30+
_version: undefined,
31+
sentences,
32+
transcript: fullTranscript,
33+
});
34+
}
35+
$.export("$summary", `Successfully fetched ${results.length} transcript${results.length === 1
36+
? ""
37+
: "s"}`);
38+
return results;
39+
},
40+
};

components/twilio/actions/list-calls/list-calls.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "twilio-list-calls",
66
name: "List Calls",
77
description: "Return a list of calls associated with your account. [See the documentation](https://www.twilio.com/docs/voice/api/call-resource#read-multiple-call-resources)",
8-
version: "0.1.3",
8+
version: "0.1.4",
99
type: "action",
1010
props: {
1111
twilio,

components/twilio/actions/list-message-media/list-message-media.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "twilio-list-message-media",
66
name: "List Message Media",
77
description: "Return a list of media associated with your message. [See the documentation](https://www.twilio.com/docs/sms/api/media-resource#read-multiple-media-resources)",
8-
version: "0.1.3",
8+
version: "0.1.4",
99
type: "action",
1010
props: {
1111
twilio,

0 commit comments

Comments
 (0)