Last active
December 30, 2020 21:03
-
-
Save Adrian-Samuel/2295cef3edfa0c41a8428f0109fd9e12 to your computer and use it in GitHub Desktop.
A script to extract all the responses to a certain number to a spreadsheet using the twilio cli
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
#! /bin/bash | |
read -p "Please enter in the full number " assignedNumber | |
smsExportFile="$assignedNumber"_Responses_$(date +'%Y-%m-%d')".csv" | |
twilio api:core:messages:list --to=$number --properties=body,from,dateSent -o=tsv > $smsExportFile | |
# no need to custom parse the JSON | |
# twilio api:core:messages:list | | |
# grep "inbound" | | |
# grep "$assignedNumber" | | |
# awk '{print $1}' | | |
# xargs -I {} twilio api:core:messages:fetch --sid {} -o json | | |
# jq '.[]| "\"" + .body + "\"" + "," + "\"" + .from + "\"" + "," + "\"" + (.dateSent|tostring) + "\""' | | |
# sed 's/\\//g' | | |
# sed -E 's/^"(.*)"$/\1/g' >> $smsExportFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment