Skip to content

Instantly share code, notes, and snippets.

@phaniav
Created August 28, 2017 09:54
Show Gist options
  • Save phaniav/cf03f8f62ee7c6dc891486d8df893794 to your computer and use it in GitHub Desktop.
Save phaniav/cf03f8f62ee7c6dc891486d8df893794 to your computer and use it in GitHub Desktop.
Sample LuisIntent["Help"] for slack with channel data hydration
[LuisIntent("Help")]
public async Task Help(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
var message = await activity;
var reply = context.MakeMessage();
reply.TextFormat = "markdown";
reply.Text = @"You can try some of the below options
* find me sweaters
* do you have wallets
* show me yellow v - neck sweaters";
var attachments = JArray.Parse(@"[{
'fallback': 'Required plain-text summary of the attachment.',
'color': '#36a64f',
'pretext': 'Optional text that appears above the attachment block',
'author_name': 'Bobby Tables',
'author_link': 'http://flickr.com/bobby/',
'author_icon': 'http://flickr.com/icons/bobby.jpg',
'title': 'Slack API Documentation',
'title_link': 'https://api.slack.com/',
'text': 'Optional text that appears within the attachment'
}]", new JsonLoadSettings
{
LineInfoHandling = LineInfoHandling.Ignore,
CommentHandling = CommentHandling.Ignore
});
dynamic channelData = new JObject();
channelData.text = "This is a line of text.\nAnd this is another one.";
channelData.attachments = attachments;
reply.ChannelData = channelData;
await context.PostAsync(reply);
context.Wait(this.MessageReceived);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment