Handling Interaction Payloads #85
Replies: 2 comments 1 reply
-
Morning @svisconti02! Thanks for reaching out I've just cloned the repo from scratch so I could ensure I got the same experience as someone using the library. I'm probably going to repeat some of what you've told me - but it's just to make sure I've not misunderstood anything. So I have an app with socket mode enabled. In the socket mode settings I see this screen, so as you've said - slash commands and interaction are both enabled. Then I've altered the ProcessMessages loop so that the slash command I've got returns (in my case) an action block with a button (I tweaked it a little so my console dumped out the block list I was sending) if (envelope.Payload is SlashCommand)
{
var message = JsonConvert.SerializeObject(new Acknowledge
{
EnvelopeId = envelope.EnvelopeId,
Payload = new Message
{
Blocks = new List<IMessageBlock>
{
new Section("This is from a socket....shh!"),
new Actions
{
BlockId = "testAction", Elements = new List<IMessageElement>
{
new Button { ActionId = "Test",Text="Test" }
}
}
}
}
});
Console.WriteLine(message);
await client.Send(message, token);
} Then, I think the bit that you're asking for, is I extended the if statement to handle interaction coming from the blocks else if (envelope.Payload is BlockActionsPayload)
{
} When I click on the button (although it doesn't respond to anything) it will hit a breakpoint in this else statement when someone interacts with the blocks. You could also check the envelope type, as this is what I do in the else if (envelope.Type == "interactive") Hope this helps - please let me know! |
Beta Was this translation helpful? Give feedback.
-
Hi @svisconti02 - it doesn't matter how the blocks get sent, all slash commands, interactive elements and events will be sent through that loop if they're enabled in the socket mode settings 👍 |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm calling a method ProcessMessages() based on the SocketSample, which will DM a set of interactive blocks to a user upon recieving a slash command. This works as expected; however, I'm failing to receive any sort of envelope when interacting with the blocks. Interactivity is enabled on the application, and I have been able to receive slash commands as well, so I'm wondering what is going wrong. I appreciate any help, thanks!
private static async Task ProcessMessages(SocketModeClient client, CancellationToken token)
{
await foreach (var envelope in client.EnvelopeAsyncEnumerable(token))
{
Beta Was this translation helpful? Give feedback.
All reactions