Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Block data from webhook payload #1257

Open
Nilura opened this issue Feb 3, 2024 · 0 comments
Open

Get Block data from webhook payload #1257

Nilura opened this issue Feb 3, 2024 · 0 comments

Comments

@Nilura
Copy link

Nilura commented Feb 3, 2024

here is the paylaod that I used to invoke Webhook

{
"text": "ERROR",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "> Danny Torrence left the following review for your property:"
}
}
]
}

Is there any way to get that all info and post to a different channel
currently only can get text

func handleInteractiveCallback(interactiveCallback slackevents.EventsAPIEvent, client *slack.Client, errorChannelID string) error {

switch interactiveCallback.Type {
// First we check if this is an CallbackEvent
case slackevents.CallbackEvent:

	innerEvent := interactiveCallback.InnerEvent

	switch ev := innerEvent.Data.(type) {
	case *slackevents.MessageEvent:
		err := handleMessageEvent(ev, client, errorChannelID)
		if err != nil {
			return err
		}
	}

default:
	return errors.New("unsupported event type")
}
return nil

}

func handleMessageEvent(event *slackevents.MessageEvent, client *slack.Client, errorChannelID string) error {
botInfo, err := client.AuthTest()
if err != nil {
return fmt.Errorf("failed to get bot info: %w", err)
}

if event.User == botInfo.UserID {
	log.Printf("Ignoring own bot message: %s", event.Text)
	return nil
}
text := strings.ToLower(event.Text)

if strings.Contains(text, "error") {

	_, _, _ = client.PostMessage(errorChannelID, slack.MsgOptionText(event.Text, false))

	return nil
}

return nil

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant