Skip to content

vanishtachangeaTwilio/SendgridMigration-Nodejs

Repository files navigation

Migration Scripts Overview

This Node.js application allows you to execute a few scripts to migrate data from one Sendgrid account to another Sendgrid account. Example of Data include: Suppressions and Templates. (as of February 2023) The scripts use Sendgrid APIs to retrieve data from one account (source account) and then recreating those data into another account (destination account).

Each script will execute some GET API Requests to retrieve some records, followed by POST API Requests which create new records with the data retrieved from the source account, into the destination account

Prerequisite

You must have access to both Source and Destination Accounts so that you can create API Keys in each account to be used in the API Requests.

Attention

  • BEWARE THESE CODES ARE NOT PRODUCTION READY; HAVE NOT BEEN FULLY TESTED;
  • THEY CAN JUST BE USED AS A GUIDE
  • PLEASE READ THE CODE.
  • THERE ARE COMMENTED CODE WHICH CREATE RECORD!!

How To Run The Scripts

Steps To Run MigrateTemplates.js

This script gives an example of which APIs could be used to migrate templates from one account to another programmatically.

This is just an example which has not been fully optimised and tested.

  1. Read the Code to uncomment the lines of code to execute the POST requests to create template and template versions
  2. run the following in the terminal
export  apiKeySrcTemplate=<sgKeySource>
export  apiKeyDestTemplate=<sgKeyDestination>
  1. run following
npm run migrate-templates

Steps To Run MigrateSuppressions.js

This script gives an example of which APIs could be used to migrate suppressions (blocks, bounces, global unsubscribes, invalid, spam reports) from one account to another programmatically.

This is just an example which has not been fully optimised and tested.

  1. run the following in the terminal
export  apiKeySrc=<sgKeySource>
export  apiKeyDest=<sgKeyDestination>
  1. run following in the terminal
npm run migrate-sup

Limitations - Next Steps To do

  • There is no code for migrating suppressions group. For that we need to:
    • Create suppression group
    • Get the suppressions from previous group in old account
    • Add those suppressions in the new group in new account.

Steps To Generate csv with dummy emails - Run generate-CSV-With-PseudoEmails

chmod 700 generate-CSV-With-PseudoEmails.sh
./generate-CSV-With-PseudoEmails.sh

Steps To Run migrateSuppressionsFromCSV.js

_This script gives an example of which APIs could be used to add emails from a csv into the global unsubscribe list using the following endpoint https://www.twilio.com/docs/sendgrid/api-reference/suppressions-global-suppressions/add-recipient-addresses-to-the-global-suppression-group

This is just an example which has not been fully optimised and tested.

  1. run the following in the terminal
export  apiKeyDest=<sgKeyDestination>
export csvFilePath=/<>/<>/pseudo_emails.csv
  1. run following in the terminal
npm run addemails-csv-to-globalsup

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published