- Add the .env file as noted below
npm install
node db.js
to create your sqlite dbnode app.js
to collect the conversations
This Node.js repository exports Drift Conversations transcripts into a CSV file labeled DriftCSV-exportDate. Conversations that meet filter criteria, are passed to CSV file upon calling app.js file.
- A Drift App API Key.
- Required Auth Scopes:
- conversation_read
- user_read
- contact_read
- Required Auth Scopes:
- CSV Writer library [In this example - csv-writer from NPM].
Clone this repo and navigate to the repo's top level directory (bulkExport). Install node dependencies
npm install
Create a .env file at the repo's top level directory that holds your oAuth token generated by creating an app DRIFT_AUTH_TOKEN
. [Here is how to create a Drift App]
Note :
Run app.js
in your terminal
The Export function is triggered upon call via the terminal. The export function runs app.js
which first retrieves the API keys from .env file.
Then, the Drift reports API is queried to retrieve all conversations that were updated within the provied time range, are currently closed and had an agent participate. The app then loops through each conversation returned and adds additional data via calls to Drift's other API endpoints. When the loop is complete, the app bundles the data into CSV file format and sends the associated data to ExportFiles folder via the csv-writer library.
Errors are logged in the console.
If no errors occur, all conversations initially returned by Drift are bulk uploaded to the CSV file in a separated row. Each time the app is run, a new file is generated with naming convention of execution time [DriftCSV-Mon Dec 13 2021 16:16:49 GMT-0800 (Pacific Standard Time).csv]
This app is read-only from Drift and write-only to the CSV file.