Closed TheRealAlexV closed 4 years ago
The insert invite script can be run using:
export SERVICE_TYPE="twilio"
export MESSAGING_SERVICE_SID="MSTwilioMessagingServiceSID"
export ACCOUNT_SID="ACTwilioAccountSID"
export UNENCRYPTED_AUTH_TOKEN="SecretTwilioAuthToken"
yarn util:insert-invite myinvitename --include-env
If you already have an organization set up, it may be easier just to insert the messaging service records manually:
# Make sure that SESSION_SECRET is set to your production value in .env before:
$ node ./dev-tools/symmetric-encrypt.js SecretTwilioAuthToken
# copy the output
$ psql "postgres://my_prod_postgres_conncection_string"
psql> \set my_existing_org_id 1
psql> insert into messaging_service (organization_id, service_type, messaging_service_sid, account_sid, encrypted_auth_token)
values (:my_existing_org_id, 'twilio', 'MSTwilioMessagingServiceSID', 'ACTwilioAccountSID', 'OutputFromSymmetricEncrypt');
Problem
When adding contacts via csv file to a campaign, if twilio is set as the default messaging service in the .env file (DEFAULT_SERVICE=twilio) the import hangs because we have not added any messaging services to the database yet and thus matching a contacts to messaging services is failing. The full error is below:
If you want to take on this issue, I can give you access to our development spoke server which has an active twilio api setup on it. Just let me know.
To reproduce this issue on a local machine, you must setup a twilio account and add a pair of test credentials as per these docs: https://www.twilio.com/docs/iam/test-credentials
Resolution
Ben Chrobot one of the lead politics Rewired devs (what this spoke is forked from) offered this resolution:
"Based on the logs it seems like you have not added any messaging services to the database yet and thus matching a contacts to messaging services is failing. We use the insert-invite.js script to generate an invite that will auto-populate a messaging service when the invite is redeemed. You can insert a messaging service manually, but will need to use the symmetric-encrypt utility to encrypt the auth token."
To close
I'm not a JS guy so I'm a little unclear on ben's instructions. I'm thinking a backend guy can handle this better than I can. When this is solved, can you just document in plain non-programmer lingo (something a devops guy will understand) how to resolve this? This won't be the last time we run into this issue.