https://retellai.com/?utm_source=discord&utm_medium=seo logo
Inbound SMS webhook doesn't appear to work
# ❓・bug-report
a
I've added an inbound SMS webhook to the phone number associated with a chat agent. The phone number is a twilio number bought from twilio. The agent responds to SMS messages and works as expected, but never posts anything to the webhook endpoint. I want to use the webhook to provide context for the chat. The webhook end point works - I can POST to it using postman and get a response. Am I missing something from the setup? We're using webhooks for the same phone number for voice, they work, as well as account level webhooks, which also works for calls.
s
hi @am4c130d For inbound SMS webhooks to work with your Twilio number and chat agent, you need to configure the inbound_webhook_url on your phone number.
This webhook is different from voice call webhooks and is specifically for handling inbound SMS messages.
a
Thanks, the webhook is configured on the phone number. I have one for voice, and a different one for SMS
s
check this document brother
a
@shahretell two way SMS is already working as I stated. The issue I described, and need to solve, is how to get the retell agent to post to a webhook on n8n to receive context info. n8n webhook is configured with the phone number in retellai as inbound SMS (not call) - as you confirmed it should be, but retellai is not sending anything to the webhook.
@shahretell wanted to put this back on your radar, there appears to be an issue - either config, bug or non-feature. The docs don't have a lot of info on SMS webhooks, and the AI agents are just trained on the docs, so I need help to move this forward.
c
Were you ever able to figure out how to get an SMS agent to fire a webhook?
@am4c130d For me it seems like there is no webhook firing on any sms communication no matter where the webhook url is set: Within the agent, at the phone number level or at the workspace level.
In fact a conversation ID isnt even created if a user sends an SMS message to an agent. You can verify this by calling the endpoint list-chats
I think I found the solution. The agent needs to have at least one post chat analysis variable in it otherwise the webhook will not fire. I was able to replicate this by adding a post chat analysis variable, then checking to see the webhook does fire. Then I deleted the post chat analysis variable and the webhook does not fire.
There is still an edge case where the webhook will not fire: If the user replies to the chat after the chat has ended, the agent will reply back to the user. However, no webhook will fire and no chat id is assigned to the new communication. It essentially creates a ghost conversation without a log anywhere.
a
It's a combination of complexity and a bug. The complexity is that the webhook is only fired at the start of a conversation. To end a conversation the chat bot must transition to an end call state.
The bug is the inbound webhook response is not documented and is inconsistent with the voice side. The term bug was used by Retell by the way.
I haven't retested it, but allegedly the correct format is to have dynamic_values at the top level of the JSON response.
@crashbot7480 sorry should have tagged you at the start. I only heard from Retell this morning that they identified the bug.
c
I wonder what this means exactly. How can you control what is at the top of the json response?
Where did they call out a bug?
a
When it was clear my issue was not been taken seriously here, I emailed them directly, and ultimately they confirmed that I had everything set up correctly and that they had discovered a bug in the inbound webhook implementation. Getting an initial webhook message for the first text in a conversation worked for me in the end. It didn't appear to work initially. I wanted to send a webhook response back to Retell that provided context for the agent, but the response was not acknowledged nor were the parameters shown in the dynamic values in the conversation analysis detail. It's the inbound webhook response that was the bug: the JSON object I was sending conformed to their documentation for inbound webooks - swapping chat_inbound for call_inbound - as the initial webhook indicated it was of type chat_inbound. The workaround/fix is to not add chat_inbound at the top level of the JSON object.