Home > Blockchain >  How can I connect to a SQL Server database from within a Twilio function
How can I connect to a SQL Server database from within a Twilio function

Time:06-09

When a text message comes in to my Twilio number, I would like the associated function to query my SQL Server database to be able to determine if I have a name associated with this number.

Can I connect from within the node.js code that my Twilio function is written in to an external database?

CodePudding user response:

You can connect to a SQL database from within a Twilio Function. I recommend you read this blog post, which is a good example of connecting to a MySQL database from a Twilio Function. In the blog post, the code uses the mysql Node package to connect to a database and send SQL commands. For SQL Server you can use the node-mssql package. You could also use an ORM to make it easier to make requests.

The blog post does use the older version of Functions, I recommend Function Services, but everything else should work as described.

  • Related