Twilio API call failing in production

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:

  1. It’s not a problem with access to environment variables since I’ve temporarily hardcoded in my tokens.
  2. 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).
  3. In the Netlify function logs, it does log the request, but not a response. There is no error caught.
1 Like

Hey there, @sudoshuff

Thanks for reaching out, and welcome to the Netlify Forums :netliconfetti: I have a few questions that will help us look into this further for you :slight_smile:

  • In your response, can you share your site name and function name with us?
  • Have you added console log lines to different parts of the function? If so, where are you seeing the last line of the console log printed?

Thanks!

I run into the exact same issue. Were you able to fix it?

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