Share feedback, ideas and get community help

Updated 6 months ago

startChat prefilledVariables

At a glance

The community member is trying to use the TypeBot API to start a chat and display the values of variables from the "prefilledVariables" in the bot flow. They are having trouble displaying the variable values and are unsure if it's possible to create a variable with the sessionId value within the flow.

The comments suggest that the community member may have been using the wrong ID (typebotId instead of publicId) and that they misunderstood how "prefilledVariables" work. After clarifying these issues, the community member was able to get the variables working correctly.

There is no explicitly marked answer, but the community members were able to resolve the issue through their discussion.

Useful resources
Hi,

I'm trying to use the TypeBot API to start the image.
I need to use the values ​​of the variables from prefilledVariables (/v1/typebots/{public Id}/startChat) in the bot flow.

body:

{
"isOnlyRegistering": false,
"message":"oi",
"prefilledVariables": {
"name": "john",
"email": "john@gmail.com"
}
}

Response:

{
"sessionId": "clstswkr9006baes42ue3l6uo",
"typebot": {
"id": "clssyfxgc0011dour5pthdngn",
"theme": {},
"settings": {
"general": {
"isInputPrefillEnabled": true,
"isHideQueryParamsEnabled": true,
"rememberUser": {
"isEnabled": false
}
}
}
},
"messages": [
{
"id": "s3tdlo432udonb2eh31bsk7s",
"type": "text",
"content": {
"richText": [
{
"type": "p",
"children": [
{
"text": "Teste "
},
{
"type": "inline-variable",
"children": []
}
]
}
]
}
}
]
}


I can't display the values ​​of the variables.

Where am I going wrong?

Another question: Is it possible to create a variable with the sessionId value within the flow?
1
g
P
B
16 comments
Is the variable declared? By the looks of it, you just wrote "{{name}}" without actually declaring the variable
It's declared but it doesn't work
Attachment
Captura_de_Tela_2024-02-20_as_09.18.31.png
Hmm, is it correctly published?
is published correctly. The entire flow works but does not display the variables. I tested it on my own instance and directly through my account at https://typebot.io
In fact, what you send as a response body does not match your flow screenshot
So we can't guess what's not working here.
I just tried this:
Plain Text
curl --request POST \
  --url https://typebot.io/api/v1/typebots/my-typebot-9lkozk3/startChat \
  --header 'Content-Type: application/json' \
  --data '{
  "prefilledVariables": {
    "name": "Baptiste"
  }
}'
Returns correctly:
Plain Text
{"sessionId":"clsx1twis00du102pk6ajnkxw","typebot":{"id":"clsx1rtpk0003ojy599lkozk3","theme":{},"settings":{}},"messages":[{"id":"g3xj6y00srayikf3ogewqvop","type":"text","content":{"richText":[{"type":"p","children":[{"text":"Welcome "},{"type":"inline-variable","children":[{"type":"p","children":[{"text":"Baptiste"}]}]},{"text":" !!!"}]}]}}]}
What version are you using?
I was using typebotId when I should have been using publicId. now it's working. thanks
I'm using publicId and the error persists.
I'm using version 2.22.2
Sorry!
I misunderstood how "profilledVariables" worked, I thought there was no need to create them within the flow, I was just using them by typing {{name_of_variable}}.
Now everything is working 100%!
Once again, sorry for the intrusion.
Add a reply
Sign up and join the conversation on Discord