Skip to main content
Solved

How to use array data from API request to make multiplechoice question?

  • December 17, 2024
  • 5 replies
  • 200 views

denis_ka

Currently I’m trying to build Telegram-bot from the constructor. I do API request to one service using Action “External Request”, I get data like this:
 

[
    {
        "id": 1,
        "entities_id": 0,
        "is_recursive": 0,
        "name": "Company 1",
        "comment": "",
        "ldap_field": null,
        "ldap_value": null,
        "ldap_group_dn": null,
        "date_mod": "2024-01-31 16:31:44",
        "groups_id": 0,
        "completename": "Company 1",
        "level": 1,
        "ancestors_cache": "[]",
        "sons_cache": null,
        "is_requester": 1,
        "is_watcher": 1,
        "is_assign": 1,
        "is_task": 1,
        "is_notify": 1,
        "is_itemgroup": 1,
        "is_usergroup": 1,
        "is_manager": 1,
        "date_creation": "2024-01-31 16:31:44"
    },
    {
        "id": 3,
        "entities_id": 0,
        "is_recursive": 0,
        "name": "Company 2",
        "comment": "",
        "ldap_field": null,
        "ldap_value": null,
        "ldap_group_dn": null,
        "date_mod": "2024-02-07 17:48:06",
        "groups_id": 1,
        "completename": "Company 1 > Company 2",
        "level": 2,
        "ancestors_cache": "{\"1\":1}",
        "sons_cache": null,
        "is_requester": 1,
        "is_watcher": 1,
        "is_assign": 1,
        "is_task": 1,
        "is_notify": 1,
        "is_itemgroup": 1,
        "is_usergroup": 1,
        "is_manager": 1,
        "date_creation": "2024-02-07 17:48:06"
    },
    {
...
    }
]

Then I need to create a question, where the choices are the name’s attributes’ values from those data. A question with multiple choices. And I need to create it dynamically. I mean, if I have 79 entities, then there’ll be 79 choices (values of name’s attributes), if I have 50, then there’ll be 50.
 

What I do now is trying to save these array data into custom user field “group_array” in Response Mapping. custom user field “group_array” is a user field that I’ve created in Settings. It seems like I can use it in Response Mapping:

$ →group_array

But when I want to display the value of the variable, I mean just “Send Message” Action, I use {}, but there’s no such variable. And I don’t understand why…

 

Here are the screenshots:

 

Best answer by Gustavo Boregio

You can use External Requests to store data: https://help.manychat.com/hc/en-us/articles/14281285374364-Dev-Tools-External-request

And Dynamic Content to display content in the chat application (you cannot store data in Dynamic Content requests).

And no, I don't think you can store content in Array variables - the array variable has to be managed by the API - That's the only useful way I found to make use of it.

View original
Did you find this topic helpful?

Gustavo Boregio
Forum|alt.badge.img+6

Hey ​@denis_ka this is a tricky one, and I'm don't think you'll be able to solve it the way you're doing it.

I'd try with Dynamic Requests (https://help.manychat.com/hc/en-us/articles/14281268533788-DevTools-Dynamic-block) and sending the content ready to be printed out.

You'll probably have to add something in between (Make or your own code) to give the content the format you want.

Hope this helps!


denis_ka
  • Up-and-Comer
  • December 19, 2024
Gustavo Boregio wrote:

Hey ​@denis_ka this is a tricky one, and I'm don't think you'll be able to solve it the way you're doing it.

I'd try with Dynamic Requests (https://help.manychat.com/hc/en-us/articles/14281268533788-DevTools-Dynamic-block) and sending the content ready to be printed out.

You'll probably have to add something in between (Make or your own code) to give the content the format you want.

Hope this helps!

Thanks! By the way, is there any possible way to save data (array) from GET-request into a custom user field and then use it?


denis_ka
  • Up-and-Comer
  • December 19, 2024
Gustavo Boregio wrote:

Hey ​@denis_ka this is a tricky one, and I'm don't think you'll be able to solve it the way you're doing it.

I'd try with Dynamic Requests (https://help.manychat.com/hc/en-us/articles/14281268533788-DevTools-Dynamic-block) and sending the content ready to be printed out.

You'll probably have to add something in between (Make or your own code) to give the content the format you want.

Hope this helps!

And.. how can I use Content, that I’ve got from Dynamic Requests? There’s no instructions about it.


denis_ka
  • Up-and-Comer
  • December 19, 2024
Gustavo Boregio wrote:

Hey ​@denis_ka this is a tricky one, and I'm don't think you'll be able to solve it the way you're doing it.

I'd try with Dynamic Requests (https://help.manychat.com/hc/en-us/articles/14281268533788-DevTools-Dynamic-block) and sending the content ready to be printed out.

You'll probably have to add something in between (Make or your own code) to give the content the format you want.

Hope this helps!

And, btw, by any chance can I do like: i make GET-request, I get an array of 10 entities, can I put the names of entities to Quick Responses in Multiple Choice action? I dunno, maybe with using the variable somehow?


Gustavo Boregio
Forum|alt.badge.img+6

You can use External Requests to store data: https://help.manychat.com/hc/en-us/articles/14281285374364-Dev-Tools-External-request

And Dynamic Content to display content in the chat application (you cannot store data in Dynamic Content requests).

And no, I don't think you can store content in Array variables - the array variable has to be managed by the API - That's the only useful way I found to make use of it.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings