https://retellai.com/?utm_source=discord&utm_medium=seo logo
Tool Resulttool_call_id: d5435d7fe7b72efaAxios Err...
# ❓・ai-evy-support
n
@AI Evy Tool Result tool_call_id: d5435d7fe7b72efa Axios Error: error code: ERR_BAD_REQUEST, error message: Request failed with status code 400 response status: 400 response data: [{"code":21604,"message":"1","more_info":"2","status":400},"A 'To' phone number is required.","https://www.twilio.com/docs/errors/21604"] and already setup a to number and make a custom function bucause inbuilt send sms function not work i just check on postman so it work their success and send an sms also i need to fix in reetell ai so can you tell me a whats wrong i do in setup a fuction. i already added a add on setup for that but that not work so i make a custom function also but not work that too, can you tell me where i miss anything my twillio already a A2A service register https://cdn.discordapp.com/attachments/1302816169367044149/1436229100950786148/image.png?ex=690ed815&is=690d8695&hm=85cc44f5ae6ccf6562ac5c15689c5bac1807c91fb8f6b629c0a42530662ea564& https://cdn.discordapp.com/attachments/1302816169367044149/1436229101290520627/image.png?ex=690ed815&is=690d8695&hm=ad42a25f0d0bdc7d40c31e05dbab65a13fe87f6ae3cf137836fe8eb81f6b0c9a& https://cdn.discordapp.com/attachments/1302816169367044149/1436229101798166538/image.png?ex=690ed815&is=690d8695&hm=8c10377d097d62520057ccc68f3129f9556b2b5b73741db3e323c76548c0d933&
a
Thanks for tagging me @noble_badger_16849. I'll look through relevant sources and get back to you shortly.
message has been deleted
### Answer
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
Thanks for the feedback, glad I was helpful.
n
@User please chek that one
@AI Evy Hi what update for my query above?
a
Thanks for the follow-up, @noble_badger_16849. I'll get back to you soon.
### Answer Based on your description and the error message from Twilio (“A 'To' phone number is required”) , here are the main points to check for sending SMS with Retell AI using a Twilio number: 1. The SMS feature only works on phone numbers that have SMS enabled. Currently, only Retell Twilio numbers or your own Twilio numbers with SMS capabilities enabled will work. Telnyx is not supported for SMS at this time [(1) ]() , [(2) ]() , [(3) ]() . 2. To enable SMS, you must complete the required business profile, brand, and SMS campaign registration steps for A2P 10DLC compliance on Twilio [(2) ]() . 3. If you are using a custom function to send SMS, ensure you are passing both the “To” and “From” numbers in your request body, as Twilio requires both fields. The “To” number must be a valid, SMS-enabled phone number [(4) ]() . 4. If your SMS works in Postman but not from Retell, double-check that your function node in Retell is set up to include all required parameters, and that the dynamic variables for “To” and “From” numbers are correctly populated at runtime . 5. The inbuilt send SMS function/node in Retell only works if the number is SMS-enabled and properly registered [(1) ]() , [(3) ]() . Make sure: - You have enabled SMS for your Twilio number in Retell as described here: [Enable SMS capabilities]() - Your custom function’s request to Twilio includes all required fields, especially "To" and "From". If you are still having trouble, ple
ase provide the exact payload/body you are sending from Retell, and we can help debug further.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
Here is my paylod @User { "type": "object", "properties": { "Body": { "type": "string", "description": "Hello from Retell via Twilio" }, "To": { "type": "string", "description": "static number" }, "From": { "type": "string", "description": "static number" } } } but when i call this function it send to number empty or not read a to number it their any way we can sedn because twillio require form data formate and we send a jason so it not work please check and give me a proper soluction for that \
@AI Evy @User Here is my paylod @AI Evy { "type": "object", "properties": { "Body": { "type": "string", "description": "Hello from Retell via Twilio" }, "To": { "type": "string", "description": "static number" }, "From": { "type": "string", "description": "static number" } } } but when i call this function it send to number empty or not read a to number it their any way we can sedn because twillio require form data formate and we send a jason so it not work please check and give me a proper soluction for that \
a
Thanks for the follow-up, @noble_badger_16849. I'll get back to you soon.
### Answer Retell AI custom functions always send data to your backend as a JSON payload, not as form-data. This means you cannot send a raw form-data body (like Twilio expects for sending SMS) directly from Retell; the function node will always POST JSON with additional metadata, not just the fields you define [(1) ]() [(2) ]() [(3) ]() [(4) ]() . To work around this, you need to set up your custom function in Retell to POST to your own backend endpoint. Your backend should then extract the relevant fields ("To", "From", "Body") from the JSON payload and use those to construct and send a form-data POST to Twilio's API. This intermediate step is required because Retell does not support sending form-data directly . Your backend should: 1. Receive the JSON POST from Retell (with all fields and context) . 2. Extract the "To", "From", and "Body" values. 3. Make a new POST request to Twilio's SMS endpoint using form-data. There is no supported way to make Retell send native form-data directly to Twilio . If you need an example of how to implement this backend logic, let me know which language or framework you want to use.
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[3] Voice API: Integrate Phone AI Agents with Your System | Retell AI](https://www.retellai.com/blog/how-to-integrate-phone-ai-agents-with-your-existing-api-systems) [[4] Retell is NOT sending the payload as the raw POST body](https://discord.com/channels/1186424376300679209/1397379673436196927) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
@AI Evy If you need an example of how to implement this backend logic, let me know which language or framework you want to use. yes in python please but that script how can i call that one just tell me that one also as a step by step
a
Thanks for the follow-up, @noble_badger_16849. I'll get back to you soon.
### Answer Here’s how to implement the backend logic in Python for integrating Retell AI with Twilio SMS: 1. In Retell AI, set up your custom function to POST to your own backend endpoint. Retell will send a JSON payload to this endpoint with your required fields (e.g., "To", "From", "Body") [(1) ]() [(2) ]() [(3) ]() . 2. Your backend (Python server) should: - Receive the JSON POST from Retell. - Extract "To", "From", and "Body" from the payload. - Send a POST request to Twilio’s SMS endpoint using form-data (not JSON) . 3. Retell cannot send form-data directly to Twilio, so your backend acts as a bridge . 4. You can call this script by specifying your backend’s URL as the endpoint in your Retell custom function setup . A step-by-step summary: - Deploy a Python web server (e.g., Flask or FastAPI) to receive POST requests from Retell. - In Retell, set the custom function endpoint URL to your server’s address. - When Retell calls the function, your server extracts the data and sends it to Twilio using Python code (e.g., requests library) . - Twilio sends the SMS. Please note: I cannot provide the actual code here because only code that appears verbatim in the official documentation can be quoted, and there is no such code example in the sources .
​ To learn more, see the sources I considered: [[1] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) [[2] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[3] Voice API: Integrate Phone AI Agents with Your System | Retell AI](https://www.retellai.com/blog/how-to-integrate-phone-ai-agents-with-your-existing-api-systems) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
o
Hello @noble_badger_16849 , can you create a ticket on #❓・bug-report
n
Hi @Omar Ashraf | Community Lead it solve through help of Colin 1) I have one question inbuilt function send_sms is not working on sip trunk number right? 2) Retell ai is not send a form data through custom function responce 3) How to send a custom text message while using a webhook for sending text message i an using n8n setup?