Exemplo n.º 1
0
        public static String ButtonTemplate(String recepid, String text, List <ResponseButtons> list)
        {
            BotMessageResponse response = new BotMessageResponse
            {
                recipient = new BotUser {
                    id = recepid
                },
                message = new MessageResponse
                {
                    attachment = new MessageAttachment
                    {
                        type    = "template",
                        payload = new MessageAttachmentPayLoad
                        {
                            template_type = "button",
                            text          = text,
                            buttons       = list
                        }
                    }
                }
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None,
                                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 2
0
        public static String GenericTemplate(String recipientId, String title, String subtitle, String imageS, List <ResponseButtons> list)
        {
            BotMessageResponse response = new BotMessageResponse {
                recipient = new BotUser {
                    id = recipientId
                },
                message = new MessageResponse
                {
                    attachment = new MessageAttachment
                    {
                        type    = "template",
                        payload = new MessageAttachmentPayLoad
                        {
                            template_type = "generic",
                            elements      = new List <PayloadElements>
                            {
                                new PayloadElements
                                {
                                    title     = title,
                                    image_url = imageS,
                                    subtitle  = subtitle,
                                    buttons   = list
                                }
                            },
                        }
                    }
                }
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None,
                                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 3
0
        public static String ImageUrlTemplate(String recepid, String uri)
        {
            BotMessageResponse response = new BotMessageResponse
            {
                recipient = new BotUser {
                    id = recepid
                },
                message = new MessageResponse
                {
                    attachment = new MessageAttachment
                    {
                        type    = "image",
                        payload = new MessageAttachmentPayLoad
                        {
                            url = uri
                        }
                    }
                }
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None,
                                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 4
0
        public static String ListTemplate(String receiveid, List <PayloadElements> elementslist, List <ResponseButtons> bts = null)
        {
            BotMessageResponse response = new BotMessageResponse
            {
                recipient = new BotUser {
                    id = receiveid
                },
                message = new MessageResponse
                {
                    attachment = new MessageAttachment
                    {
                        type    = "template",
                        payload = new MessageAttachmentPayLoad
                        {
                            template_type     = "list",
                            top_element_style = "compact",
                            elements          = elementslist,
                            buttons           = bts
                        }
                    }
                }
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None,
                                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemplo n.º 5
0
        public static String SimpleTextTemplate(String recipientId, String text)
        {
            BotMessageResponse response = new BotMessageResponse
            {
                recipient = new BotUser {
                    id = recipientId
                },
                message = new MessageResponse
                {
                    text = text
                }
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.None,
                                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }