Reg: Creation of PayLoad At Runtime using C#

56 views
Skip to first unread message

Amar B

unread,
Dec 2, 2021, 3:36:25 AM12/2/21
to Dialogflow Essentials Edition users
Hello Everyone,

I am trying to create the payload at run time using C#, as mentioned below:

                var button1 = Value.ForStruct(new Google.Protobuf.WellKnownTypes.Struct
                {
                    Fields =
                                {
                                     ["payload"] = Value.ForString("Save"),
                                    ["text"] = Value.ForString("Con")
                                }
                });
                var button2 = Value.ForStruct(new Google.Protobuf.WellKnownTypes.Struct
                {
                    Fields =
                                {
                                    ["payload"] = Value.ForString("CANC"),
                                    ["text"] = Value.ForString("Can")
                                }
                });
                Value[] val = { button1, button2 };
                var payload = new Struct
                {
                    Fields = {
                                    ["quick_replies"] = Value.ForList(val),
                                    ["text"] = Value.ForString("To Continue, Please click on Below."),
                                    ["isRemovable"] = Value.ForBool(true)
                                }
                };
                Google.Protobuf.WellKnownTypes.Struct sd = new Google.Protobuf.WellKnownTypes.Struct(payload);
                response.Payload = sd;
return Content(response.ToString(), "application/json");

But using above code, i am not able to create the Custom Payload. 
Please let me know your valuable inputs.


Regards,
Amarendra.

Rodrigo Jara

unread,
Dec 6, 2021, 11:55:29 AM12/6/21
to Dialogflow Essentials Edition users

Hi, 

This kind of technical questions would be more appropriate for Stack Sites. Post it here to get code guidance on your Dialogflow ES payload creation.

Please bear in mind that you’ll need to consider these guidelines on how to post a good question to get the best answers.

Reply all
Reply to author
Forward
0 new messages