How to send metadata (extra info) in Restful api bot response (bot side)?

What is an optimal way of sending extra information (metadata) in the response message (from bot side) in restful api (webhooks/rest/webhook).

To be clear, I want to send some metadata along with the form question (and every other bot utterance) so that the mobile side could know how to configure the interface based on that info.

For example, now the response has the following structure:

[
    {
        "recipient_id": "1",
        "text": "What color do you prefer?"
    }
]

But I would like it to be like this:

[
    {
        "recipient_id": "1",
        "text": "What color do you prefer?",
        "type": "color_question" 
    }
]

Are there any implemented ways for doing this?

Any ideas?"

Hey @taguhi, you can send the metadata using utter_custom_method. Check this out, it may help you:

Restaurant-Search-Bot/actions.py at bcc069e2d10b71ae78f0989484373e43ca70cc65 · JiteshGaikwad/Restaurant-Search-Bot · GitHub

Thanks for the response @JiteshGaikwad.

I looked it through but there is still one problem. I have a form action and there is nowhere to manually write dispatcher.utter_custom_json({"payload": "something"}) line. I would like my form action to send specific payloads with each question in the form.

Is there a way to include it in domain.yml file?

Well I guess I found the answer here Domains

Hey @taguhi, check out this:

Thanks! It worked.

@JiteshGaikwad I’m sorry, one more question :slight_smile:

I didn’t find anywhere in the documentation about the difference between elements and payloads. When to use which one?