-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
516 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import app from "../../leexi.app.mjs"; | ||
|
||
export default { | ||
key: "leexi-create-call", | ||
name: "Create Call", | ||
description: "Create a new call in Leexi. [See the documentation](https://developer.leexi.ai/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
recordingS3Key: { | ||
type: "string", | ||
label: "Recording S3 Key", | ||
description: "The S3 key returned by the presign_recording_url endpoint.", | ||
}, | ||
externalId: { | ||
type: "string", | ||
label: "External ID", | ||
description: "The ID of the call in your system.", | ||
}, | ||
integrationUserExternalId: { | ||
type: "string", | ||
label: "Integration User External ID", | ||
description: "The external ID of the user making the call on your platform.", | ||
}, | ||
integrationUserName: { | ||
type: "string", | ||
label: "Integration User Name", | ||
description: "The name of the user making the call on your platform.", | ||
}, | ||
direction: { | ||
type: "string", | ||
label: "Call Direction", | ||
description: "The direction of the call (inbound or outbound).", | ||
options: [ | ||
"inbound", | ||
"outbound", | ||
], | ||
}, | ||
performedAt: { | ||
type: "string", | ||
label: "Performed At", | ||
description: "The start time of the call, in ISO8601 format. Eg. `2024-01-09T17:05:09+01:00`", | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "A description of the call.", | ||
optional: true, | ||
}, | ||
rawPhoneNumber: { | ||
type: "string", | ||
label: "Phone Number", | ||
description: "The phone number of the caller.", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
createCall(args = {}) { | ||
return this.app.post({ | ||
path: "/calls", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createCall, | ||
recordingS3Key, | ||
externalId, | ||
integrationUserExternalId, | ||
integrationUserName, | ||
direction, | ||
performedAt, | ||
description, | ||
rawPhoneNumber, | ||
} = this; | ||
|
||
const response = await createCall({ | ||
$, | ||
data: { | ||
recording_s3_key: recordingS3Key, | ||
external_id: externalId, | ||
integration_user: { | ||
external_id: integrationUserExternalId, | ||
name: integrationUserName, | ||
}, | ||
direction, | ||
performed_at: performedAt, | ||
description, | ||
raw_phone_number: rawPhoneNumber, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully created a new call."); | ||
return response; | ||
}, | ||
}; |
78 changes: 78 additions & 0 deletions
78
components/leexi/actions/create-presign-recording-url/create-presign-recording-url.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { readFileSync } from "fs"; | ||
import app from "../../leexi.app.mjs"; | ||
|
||
export default { | ||
key: "leexi-create-presign-recording-url", | ||
name: "Create Presigned Recording URL", | ||
description: "Creates a presigned URL for uploading a call recording. [See the documentation](https://developer.leexi.ai/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
extension: { | ||
propDefinition: [ | ||
app, | ||
"extension", | ||
], | ||
}, | ||
filePath: { | ||
type: "string", | ||
label: "File Path", | ||
description: "The path to the file to upload. Eg. `/tmp/recording.mp3`", | ||
}, | ||
}, | ||
methods: { | ||
createPresignedRecordingUrl(args = {}) { | ||
return this.app.post({ | ||
path: "/calls/presign_recording_url", | ||
...args, | ||
}); | ||
}, | ||
uploadFile(args = {}) { | ||
return this.app.put({ | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
uploadFile, | ||
createPresignedRecordingUrl, | ||
extension, | ||
filePath, | ||
} = this; | ||
|
||
const response = await createPresignedRecordingUrl({ | ||
$, | ||
data: { | ||
extension, | ||
}, | ||
}); | ||
|
||
if (!response.success) { | ||
$.export("$error", "Failed to create a presigned URL for recording."); | ||
return response; | ||
} | ||
|
||
const { | ||
data: { | ||
headers, | ||
url, | ||
}, | ||
} = response; | ||
|
||
const path = filePath?.startsWith("/tmp") | ||
? filePath | ||
: `/tmp/${filePath}`; | ||
|
||
await uploadFile({ | ||
$, | ||
headers, | ||
url, | ||
data: readFileSync(path), | ||
}); | ||
|
||
$.export("$summary", "Successfully created a presigned URL for recording"); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import app from "../../leexi.app.mjs"; | ||
|
||
export default { | ||
key: "leexi-get-call", | ||
name: "Get Call", | ||
description: "Get details of a call by its ID. [See the documentation](https://developer.leexi.ai/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
callId: { | ||
propDefinition: [ | ||
app, | ||
"callId", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
getCall({ | ||
callId, ...args | ||
} = {}) { | ||
return this.app._makeRequest({ | ||
path: `/calls/${callId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
getCall, | ||
callId, | ||
} = this; | ||
|
||
const response = await getCall({ | ||
$, | ||
callId, | ||
}); | ||
$.export("$summary", `Successfully retrieved details for call ID \`${response.data?.uuid}\`.`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const BASE_URL = "https://public-api.leexi.ai"; | ||
const VERSION_PATH = "/v1"; | ||
const LAST_CREATED_AT = "lastCreatedAt"; | ||
const DEFAULT_LIMIT = 100; | ||
const DEFAULT_MAX = 300; | ||
|
||
const EXTENSION_OPTIONS = [ | ||
".mp4", | ||
".mkv", | ||
".avi", | ||
".webm", | ||
".mov", | ||
".wmv", | ||
".mpg", | ||
".mpeg", | ||
".mp3", | ||
".wav", | ||
".aac", | ||
".flac", | ||
".ogg", | ||
".m4a", | ||
".wma", | ||
".opus", | ||
".aiff", | ||
".alac", | ||
".amr", | ||
".ape", | ||
".dts", | ||
".ac3", | ||
".mid", | ||
".mp2", | ||
".mpc", | ||
".ra", | ||
".tta", | ||
".vox", | ||
]; | ||
|
||
export default { | ||
BASE_URL, | ||
VERSION_PATH, | ||
DEFAULT_LIMIT, | ||
DEFAULT_MAX, | ||
LAST_CREATED_AT, | ||
EXTENSION_OPTIONS, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
async function iterate(iterations) { | ||
const items = []; | ||
for await (const item of iterations) { | ||
items.push(item); | ||
} | ||
return items; | ||
} | ||
|
||
export default { | ||
iterate, | ||
}; |
Oops, something went wrong.