https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is there a way in a function to pass in what the u...
# ❓・ai-evy-support
c
@AI Evy Is there a way in a function to pass in what the user has replied?
a
Thanks for tagging me @Ciaran. I'll look through relevant sources and get back to you shortly.
​ To learn more, see the sources I considered: [[1] How to pass in variables in the General Tool / State Tool function calls?](https://discord.com/channels/1186424376300679209/1229563946378203188) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
### Answer Yes, you can pass user responses into a function call. When defining a custom tool, you specify parameters in a JSON schema, and the LLM will automatically extract and pass the relevant values from the conversation. [(1) ]() For example, if you need to collect an email address from the user and pass it to a function, you can: 1. Define the parameter (e.g.,
email
) in your tool's JSON schema 2. In your prompt, instruct the agent how to use that value—for example: "Use the email mentioned by the customer and call the xyz function with that" The LLM will automatically pick up the value provided by the user during the conversation and pass it as an argument when invoking the function. Additionally, when a custom function is called, the request body includes the full
transcript
of the conversation, which contains all user and agent utterances with word-level timestamps. [(2) ]() Here's a snippet of what the request body looks like:
Copy code
json
"transcript": [
  {
    "role": "user",
    "content": "Yes, it's 78542.",
    "words": [
      { "word": "Yes,", "start": 11.5, "end": 11.8 },
      { "word": "it's", "start": 11.9, "end": 12.1 },
      { "word": "78542.", "start": 12.2, "end": 12.9 }
    ]
  }
]
This gives your function access to everything the user has said during the call.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy So what if the user said 'Hello, how are you', I want to pass that in. Currently just using this in the parameters "prompt": { "type": "string", "description": "What the user has said" },
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer Your approach with defining a
prompt
parameter should work—the LLM will extract what the user said and pass it as the argument value. [(1) ]() However, you also have access to the full transcript in the request body that Retell sends to your custom function endpoint. When your function is called, the request includes a
transcript
array containing all user and agent utterances. [(2) ]() So you have two options: 1. Use your parameter approach — The LLM will fill in the
prompt
parameter with the user's utterance. Make sure your agent prompt explicitly instructs when to call this function with the user's message. 2. Access the transcript directly — Your endpoint receives the complete conversation history in the request body. You can parse the
transcript
array to get the latest user message:
Copy code
json
"transcript": [
  {
    "role": "user",
    "content": "Hello, how are you",
    "words": [
      { "word": "Hello,", "start": 4.0, "end": 4.3 },
      { "word": "how", "start": 4.4, "end": 4.6 },
      { "word": "are", "start": 4.6, "end": 4.8 },
      { "word": "you", "start": 4.8, "end": 4.9 }
    ]
  }
]
In your backend code, you can extract the most recent user message from this transcript array rather than relying solely on the LLM to pass it as a parameter.
​ To learn more, see the sources I considered: [[1] How to pass in variables in the General Tool / State Tool function calls?](https://discord.com/channels/1186424376300679209/1229563946378203188) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
c
@AI Evy But it's not telling me that... It comes to with me 'The user has asked how we are, the user seems happy.' when all I said 'Hello, how are you'
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer The issue is that the LLM is interpreting/summarizing the user's message rather than passing it verbatim. This happens because your description says "What the user has said"—the LLM treats this as a semantic extraction task. Two solutions: 1. Be more explicit in your parameter description: Update your description to explicitly request the exact words:
Copy code
json
"prompt": {
  "type": "string",
  "description": "The exact verbatim text of what the user just said, word for word, without interpretation or summarization"
}
[(1) ]() 2. Use the transcript from the request body instead: When Retell calls your custom function, the request body includes the full
call
object with the real-time transcript. You can parse this in your backend to get the exact user utterance:
Copy code
json
"call": {
  "transcript": [
    {
      "role": "user",
      "content": "Hello, how are you",
      "words": [...]
    }
  ]
}
This approach is more reliable because you're reading the actual transcribed speech directly from the transcript array, rather than depending on the LLM to pass it accurately as a parameter. In your endpoint code, simply grab the last user message from the transcript array—this will always be the exact transcription without any LLM interpretation.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) ​
c
@AI Evy Option 1 worked 🙂
a
Thanks for the follow-up, @Ciaran. I'll get back to you soon.
### Answer Great to hear! Being explicit in your parameter description is key—telling the LLM to pass the "exact verbatim text...word for word, without interpretation or summarization" ensures you get the actual user utterance rather than a summary. [(1) ]() If you ever need a fallback, remember you can also access the raw transcript directly from the request body that Retell sends to your endpoint. [(1) ]() [(2) ]()
​ To learn more, see the sources I considered: [[1] Integrate any system with custom function](https://docs.retellai.com/build/single-multi-prompt/custom-function) [[2] Custom Function](https://docs.retellai.com/build/conversation-flow/custom-function) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.