0

Currently I'm working on a survey system using Twilio Studio and I need to query a database using Twilio Functions/Services, a SQL Server database. I've created the database table in SQL Server Management Studio, how do I connect to it via a Twilio Service using the mssql package?

1 Answers1

0

It sounds like you installed MSSQL Server on your machine, and want to connect to it from a Twilio Function.

You'll need to do two things for that:

  1. make your localhost SQL Server publicly accessible over the internet
  2. use a node.js library to connect to the SQL server and start querying it

If your Twilio Function is running on Twilio's platform, then it won't be able to access anything that's on your personal computer/localhost. For development purposes, you can use ngrok to open a public TCP port that forwards traffic from the internet to your localhost SQL server. ngrok is one of many tunneling services that you can use to accomplish this. This will solve problem 1. In production, you wouldn't use a tunnel, but configure your SQL Server VM or service to be publicly available.

You can use a library or driver to work with SQL Server from node.js like tedious. Use the forwarding URL ngrok gives you to connect with the node.js library.

Swimburger
  • 6,681
  • 6
  • 36
  • 63