I’m having a problem where I use the Twilio Node.js to send a text message. After creating the Twilio client object and passing in my credentials, I make a call to client.messages.create() to send the SMS. This works perfectly fine in my local environment, but fails in production with no errors.
Here’s what I know:
It’s not a problem with access to environment variables since I’ve temporarily hardcoded in my tokens.
When I enable debug level logging of the Twilio client, on my local machine it logs both a request and response (and of course the SMS is sent successfully).
In the Netlify function logs, it does log the request, but not a response. There is no error caught.
Hi, @l5t. This person didn’t reply to our requests for some basic details to begin troubleshooting (the site and function name). Based on this, it is unlikely they will reply again here. They might, though.
If you are willing to share those details here for your site (the site and function names), our support team will do our best to assist with troubleshooting.
My first recommendation would be to console.log() the responses to the function logs for any failed API calls. The API response should have clues about why the API called failed. If you log that response to the function logs, it might explain the root cause.
Thanks @luke for your reply. Sure happy to share more details.
Here is the the site and function Netlify App
I have use console.log extensively and like reported above, I’m sure there is something weird when using locally. It works in production but locally for some reason event.body is undefined
Could you please share what you’re doing inside the function and how we can test this? What data is the function expecting, what’s the expected output?