The current template looks like this:
This is the code used to build this "Send secret message":
import (
"fmt"
"strings"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/slack-go/slack"
)
// SendMessage sends a message to the receiver through slack
func SendMessage(id uuid.UUID, sender string, receiver string, description string) error {
username := strings.Split(receiver, "@")[0]
_, _, err := rtm.PostMessage(
"@"+username,
slack.MsgOptionText(fmt.Sprintf(
"*%s has shared a secret with you!* \n*Description:* %s "+
"\nView the secret at https://whisper.sky/%s",
sender,
description,
id), false),
slack.MsgOptionAsUser(true),
)
if err != nil {
return errors.Wrap(err, "sending message through slack")
}
return nil
}
Blockquote
However, on the slack Block Kit Builder they use Json, so my question is, can I edit the template to how I want in Json and import the Json into the code I have currently so it looks more like this:
Any help would be appreciated as I am new to this background so not sure what to change and where. Thanks.
This is the code from the block builder:
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "{name} has sent you a secret!",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Type:*\nPassword"
},
{
"type": "mrkdwn",
"text": "*For:*\nGitHub Service Account"
},
{
"type": "mrkdwn",
"text": "*Message:*\nHere's the password to the GitHub Service Account"
},
{
"type": "mrkdwn",
"text": "*Expires:*\nIn 7 Days"
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*To access this secret visit http://whisper.int.discoott.sky.com/ *"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Here",
"emoji": true
},
"value": "access_secret_button",
"url": "https://whisper.int.discoott.sky.com/",
"action_id": "button-action"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "If you did not expect this secret, you can ignore it and allow it to expire."
}
]
}
]
}
I just do not know how to implement that code into my Go file.