Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions
You are not logged in.
Pages: 1
Como posso mostrar a resposta de um rest api que retorna um array em vários botões?
Ex:
Minha REST API resposta:
{
types: [
{typeName:Button1},
{typeName:Button2},
{typeName:Button1}
]
}
Chat
Olá escolha uma opção!
[Button1] [Button2] [Button3]
Offline
Forum is english only.
Offline
Sorry, i got confused and send question in Portuguese, but my question is how to show multiple buttons from an array of a json response.
Example:
REST API response:
{
types: [
{typeName:Button1},
{typeName:Button2},
{typeName:Button3}
]
}
Show in chat like this:
Hello choose an option
[Button1] [Button2] [Button3] -> (button text from Json response)
Offline
As you see here
quick_replies are an array.
https://doc.livehelperchat.com/docs/bot … g-location
Another option is the tip described in the same article.
Offline
Hello, thanks for the help initially it worked, the options for click appeared and executed the trigger (id 21, in payload)
but trigger id 21 executes another REST API, when executing the other REST API the variable {{msg}} is empty. How I pass the result
clicked from meta_msg to a second REST API? Thanks.
meta_msg": {
"content": {
"quick_replies": [
{
"content": {
"name": "Option 1",
"payload": "21"
},
"type": "trigger"
},
{
"content": {
"name": "Option 2",
"payload": "21"
},
"type": "trigger"
}
]
}
}
Offline
I'm not sure I understand...
Visitor clicks a button. You send Rest API call. You parse response. You can store some parts of Rest API call 1 in chat variables. https://doc.livehelperchat.com/docs/bot … out-coding
And later just reuse these in call 2 etc..
Offline
I created a variable ({"card": "11111111111"}) in Trigger type "Update Current Chat" and when I tried to call the Rest API in the Response Type "Execute Action". In my REST API I created a "Sub URL" like this {{card}}, did not recognize the value "http: / myurl / 11111111111" and called like this "http: / myurl / {{card}}". What can I have done wrong.
Thank you for your help.
{
"_id": "F-hdyYb7s",
"type": "command",
"content": {
"command": "chatvariable",
"text": "{{msg}}",
"payload": "{\"cartao\":\"11111111111\"}",
"rest_api_method_output": {
"temp1593794277247": "23"
},
"rest_api": "2",
"attr_options": {
"background_process": false,
"collection_callback_match": "23",
"collection_callback_pattern": "23"
},
"rest_api_method": "temp1593794242823",
"event_background_inst": true,
"event_background": false,
"rest_api_method_params": [],
"event": "cartao selecionado",
"event_validate": "/(.*?)/"
}
},
{
"_id": "A3t0OQ6ME",
"type": "actions",
"content": {
"text": "",
"rest_api_method_output": [],
"rest_api": "2",
"attr_options": {
"collection_callback_pattern": "23"
},
"rest_api_method": "temp1593794242823",
"event_background_inst": false,
"event_background": true,
"rest_api_method_params": [],
"events": [
{
"_id": "IqYc0LiGi",
"type": "button",
"content": {
"identifier": "Executar UR86",
"trigger_id": "23"
}
}
],
"event_validate": "/(.*?)/"
}
}
Last edited by rogeriomayer (2020-07-16 14:46:18)
Offline
I still don't get what you are trying to do.
See example how I set UUID from first Rest API response and later reuse it just.
https://doc.livehelperchat.com/docs/bot … out-coding
Offline
And if you need more specific commercial support you can contact me on skype...
Offline
I just tried to create a variable and set a value like in the documentation {"card": "content_1"}, but I couldn't get the value in the REST API, or in another Trigger, instead of the set value "content_1" in the REST API the result is "{{card}}". As if the variable is not recognized. To create, just create the variable inside the Trigger or do you have any other steps? I saw another topic on the forum with the same problem, I believe it is some simple detail, but it is not clear how to use these variables.
"forum.livehelperchat.com/viewtopic.php?id=3672"
Thank you for your help.
Offline
Well,
Documentation tells everything...
In rest API definition itself you have access to all these variables.
https://doc.livehelperchat.com/docs/bot … -variables
And in trigger itself you set custom chat variable just from first response..
Offline
Custom variables is set here E.g first rest api call
https://doc.livehelperchat.com/docs/bot … ssage-send
Reused in next api call here
https://doc.livehelperchat.com/docs/bot … w-it-works
If you are collecting additional variables placehjolder in Rest API call will be
{{lhc.add. identifier}}
Offline
Hello, the variables finally worked, thanks for the help. However, a doubt arose.
I have a REST API returning a meta_msg, how can I collect the value that was clicked on the item?
Is there a way to show text on the button to the client and have another value that I will use in a variable to pass to a REST API, like a "text" and "id" of an html button?
Thanks.
meta_msg": {
"content": {
"quick_replies": [
{
"content": {
"name": "Option 1",
"payload": "21" //Ex : "How in this trigger "21" collect the option clicked and put in a variable?"
},
"type": "trigger"
},
{
"content": {
"name": "Option 2",
"payload": "21" //Ex : "How in this trigger "21" collect the option clicked and put in a variable?"
},
"type": "trigger"
}
]
}
}
Offline
When you define a trigger there is an option to choose. Default trigger for unknown button click. As it’s your custom payloads as a message you will receive payload data which you can use in rest api as user msg
Offline
It wasn't clear to me how to do it this way, I tried and it didn't work.
Can i use store_name and store_value to set value in variable?
Do you have an example of how to do it?
Thank you
Last edited by rogeriomayer (2020-07-20 19:57:37)
Offline
Default for unknown button click.
https://doc.livehelperchat.com/docs/bot … at-started
There you defined Rest API call as you do with regular messages and message itself will be just payload data.
Offline
Can i use store_name and store_value to set value in variable?
Offline
I do not understand what is store_name or store_value... on button click tou execute trigger and with response you can do whatever you want
Offline
It worked by setting the value in the Store Name and Store Value fields, like the example.
"meta_msg": {
"content": {
"quick_replies": [
{
"content": {
"button_id": "button_1",
"name": "Button 1",
"payload": "45",
"store_name": "myvariable",
"store_value": "xxxxxxxxxx"
},
"type": "trigger"
},
{
"content": {
"button_id": "button_2",
"name": "Button 2",
"payload": "45",
"store_name": "myvariable",
"store_value": "yyyyyyyyyyy"
},
"type": "trigger"
},
}
}
Offline
Yes, that's a good trick forgot about that. Now you can improve documentation and create a pull request
Offline
good day, I'm doing a Execute trigger body like this:
[
{
"type": "text",
"content": {
"text": "Please select the promissory note number.",
"quick_replies": [
{
"type": "trigger",
"content": {
"name": "custom text promissory 01",
"payload": "504",
"store_name": "myvariable",
"store_value": "0043652353"
}
},
{
"type": "trigger",
"content": {
"name": " custom text promissory 02 ",
"payload": "504",
"store_name": "myvariable",
"store_value": "0044106813"
}
}
],
"attr_options": {
"as_dropdown": true,
"hide_text_area": true
}
}
}
]
but I have not been able to print the variable in a: Add response-> Send text; I have tried like this:
{lhc.var.myvariable} -
{args.chat.chat_variables_array.myvariable} -
{{args.chat.myvariable}} -
{{lhc.add. myvariable}} -
Please could you tell me how you did it, thank you.
---------------------- EDIT ----------------------
It had a spelling error (a space) is achieved like this:
{lhc.add.myvariable}
Last edited by karlitoxz (2021-07-30 21:24:41)
Offline
Pages: 1