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

Is it possible to serialize the payload into a json? #1149

Open
darewreck54 opened this issue Dec 20, 2022 · 0 comments
Open

Is it possible to serialize the payload into a json? #1149

darewreck54 opened this issue Dec 20, 2022 · 0 comments

Comments

@darewreck54
Copy link

Currently, the postMessage api take in a list of objects to build up the payload to send to slack.

	channelID, timestamp, err := e.slackApiClient.PostMessage(
		notification.channel,
		slack.MsgOptionUsername("Bot Name"),
		slack.MsgOptionText(titleText, false),
		slack.MsgOptionAttachments(
			slack.Attachment{
				Blocks: slack.Blocks{
					BlockSet: blocks,
				},
				Color: notification.color,
			},
		),
	)

I'm wondering:

  • if it is possible to pass a json representation of the payload

In the example above, I imagine it to be something like

    e.slackApiClient.PostMessage(json)
  • does the sdk support the ability to create the payload and then serialize it to a string
    jsonPayload = e.slackApiClient.CreateMessagePayload(
		notification.channel,
		slack.MsgOptionUsername("Bot Name"),
		slack.MsgOptionText(titleText, false),
		slack.MsgOptionAttachments(
			slack.Attachment{
				Blocks: slack.Blocks{
					BlockSet: blocks,
				},
				Color: notification.color,
			},
		),
	)

Thanks,
Derek

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

No branches or pull requests

2 participants