This topic was automatically generated from Slack. You can find the original thread here.
What are the metadata_event_type and metadata_event_payload props for in the “Build and Send a Block Kit Message (Beta) with Slack API” action. Please provide a use case. I already have this info from the docs:
Metadata Event Type metadata_event_type string
The name of the metadata event
Metadata Event Payload metadata_event_payload string
The payload of the metadata event. Must be a JSON string e.g. {“key”: “value”}
The metadata_event_type and metadata_event_payload props in the “Build and Send a Block Kit Message (Beta) with Slack API” action are used to send additional information along with your Block Kit message that isn’t displayed in the message itself. This metadata can be used for tracking purposes or to include data that can be used in subsequent workflow steps when the message event is triggered. Use Case Example: Imagine you’re sending a Block Kit message to a Slack channel that includes an interactive component, like a button. When a user clicks this button, it triggers an event that your Pipedream workflow can listen for. You want to track which specific campaign or feature this interaction is associated with, but you don’t want to display this information in the message. You could use the metadata_event_type to specify the type of event, such as “campaign_interaction”, and the metadata_event_payload to include a JSON string with details about the campaign, like {"campaign_id": "12345", "feature": "new_release"}. When the button is clicked, the event triggered will include this metadata, and you can use it in your workflow to log the interaction, filter events, or take different actions based on the campaign details. Here’s a snippet of how you might set these props in a Pipedream component: export default defineComponent({ props: { slack: { type: "app", app: "slack", }, metadata_event_type: { type: "string", label: "Metadata Event Type", description: "The name of the metadata event", }, metadata_event_payload: { type: "string", label: "Metadata Event Payload", description: "The payload of the metadata event. Must be a JSON string e.g. {\"key\": \"value\"}", }, }, async run({ steps, $ }) { // ... code to send the Block Kit message with metadata ... }, }); In this example, the metadata_event_type and metadata_event_payload are used to pass additional context about the message that can be utilized later in the workflow.
when setting metadata_event_type = “task_updated” and metadata_event_payload = {"msg":"Hello"} the action fails with invalid_metadata_schema - [WARN] Message metadata was incorrectly formatted. The message metadata will be ignored as a result.
The error message you’re encountering, invalid_metadata_schema - [WARN] Message metadata was incorrectly formatted. The message metadata will be ignored as a result., suggests that the format of the metadata you’re passing to the Slack API does not meet the expected schema. According to the Slack API documentation, metadata should be an array of objects, each with a type and value property. However, based on the information you’ve provided, it seems you’re passing a JSON string with a different structure. Here’s how you should format the metadata: on [ { "type": "task_updated", "value": "{\"msg\":\"Hello\"}" } ] Each object in the array represents a piece of metadata. The type property is a string that identifies the kind of metadata (e.g., “task_updated”), and the value property is a JSON-encoded string that contains the actual metadata. If you’re using the Pipedream “Build and Send a Block Kit Message (Beta) with Slack API” action, you’ll need to ensure that the metadata_event_payload is a JSON-encoded string that represents an array of objects formatted as shown above. Here’s a hypothetical example of how you might set the metadata_event_type and metadata_event_payload in a Pipedream component: ```
export default defineComponent({ props: { slack: { type: “app”, app: “slack”, }, metadata_event_type: { type: “string”, label: “Metadata Event Type”, description: “The name of the metadata event”, }, metadata_event_payload: { type: “string”, label: “Metadata Event Payload”, description: “The payload of the metadata event. Must be a JSON string e.g. [{"type": "task_updated", "value": "{\"msg\":\"Hello\"}"}]”, }, }, async run({ steps, $ }) { // … code to send the Block Kit message with metadata … const metadata = JSON.stringify([ { type: this.metadata_event_type, value: this.metadata_event_payload, }, ]); // Use the metadata in the API request to Slack }, });