N
Novu6mo ago
vinman8866

Slack Message with Blocks configuration

Hi, I would like to send a Slack message with blocks. Here is an example of the trigger:
token = "HELLO WORLD"
event_api.trigger(
name="trigger-name",
recipients=subscriber,
payload={
"blocks" : [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f'*Asset:* {tokens}'
}
}
]
}
)
token = "HELLO WORLD"
event_api.trigger(
name="trigger-name",
recipients=subscriber,
payload={
"blocks" : [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": f'*Asset:* {tokens}'
}
}
]
}
)
How do I configure the workflow to use the blocks? e.g., I have attached a picture of the current Slack workflow. Is the only way to achieve this through the new Novu Echo framework?
No description
15 Replies
Ask Inkeep
Ask Inkeep6mo ago
Hi @vinman8866, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * How to send notifications with Next.js and MJML * How to use Novu to send notifications to a Slack channel * Trigger event * Building notification workflows with the Novu Framework ----------------------------- Answer Currently, Novu does not directly support sending Slack messages with blocks in the standard workflow configuration. (1) (2) The current Slack integration in Novu is limited to sending plain text messages with some minor styling and emojis. (2) Current Limitations: 1. The existing Slack integration in Novu only supports sending messages to a single channel or direct message. (1) (3) 2. The content from the textarea in the UI is sent directly as the text content in the Slack API request, which doesn't support block structures. (2) Potential Workarounds: 1. Novu Framework (Echo): The new Novu Framework (Echo) might offer more flexibility in configuring complex message structures like Slack blocks. (4) However, as of the latest available information, there's no specific mention of Slack block support in the Echo framework documentation. 2. Custom Integration: You might need to create a custom integration that handles the Slack API directly to send messages with blocks. This would involve bypassing Novu's built-in Slack integration and using Novu only to trigger the notification event. Future Development: There is an open feature request for supporting Slack blocks in Novu. (2) (5) The Novu team has acknowledged this request and mentioned that they are shaping their Slack integration experience, with potential i
Ask Inkeep
Ask Inkeep6mo ago
mprovements coming in the next couple of months. (5) Given the current limitations, I suggest you click on the "Ask for help" button to tag a team member for a more up-to-date answer on the status of Slack block support in Novu.
Ask Inkeep
Ask Inkeep6mo ago
Feel free to tag @Ask Inkeep with additional questions.
vinman8866
vinman8866OP6mo ago
@Ask Inkeep If the easiest way to do this is through the Novu Echo framework. Can you show me an example of a workflow with a chat step using slack with blocks and hyperlinks etc.? In the current implementation I have above, e.g., in the original way of defining a workflow in novu cloud, how do I add bold or formatting to the message
Ask Inkeep
Ask Inkeep6mo ago
Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain6mo ago
@vinman8866 checkout this doc to learn how to send slack message in slack blocks format https://v0.x-docs.novu.co/framework/steps/chat#provider-overrides
vinman8866
vinman8866OP6mo ago
Is there any documentation for users who want to migrate their current implementation with Novu Cloud to the new Novu Echo Framework? Seems a limitation in documentation @Pawan Jain
Pawan Jain
Pawan Jain6mo ago
@vinman8866 Current workflows will continue to work as it is. New workflows created from UI will also work as expected and how they are working now. Only option is to create new worklfow with V2 framework
vinman8866
vinman8866OP6mo ago
Hi @Pawan Jain - thank you. I am now receiving an unexpected provider error when I try to use the default slack blocks message you provided in the docs and trying to send to the slack provider Here is the error in two messages due to the limit of characters { "message": "Request failed with status code 400", "name": "AxiosError", "stack": "AxiosError: Request failed with status code 400\n at settle (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/axios/dist/node/axios.cjs:1967:12)\n at IncomingMessage.handleStreamEnd (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/axios/dist/node/axios.cjs:3066:11)\n at IncomingMessage.emit (node:events:531:35)\n at IncomingMessage.emit (node:domain:488:12)\n at LegacyContextManager.runInContext (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/newrelic/lib/context-manager/legacy-context-manager.js:59:23)\n at IncomingMessage.wrapped (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/newrelic/lib/transaction/tracer/index.js:203:37)\n at IncomingMessage.wrappedResponseEmit (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/newrelic/lib/instrumentation/core/http-outbound.js:313:24)\n at endReadableNT (node:internal/streams/readable:1696:12)\n at runInContextCb (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/newrelic/lib/shim/shim.js:1315:22)\n at LegacyContextManager.runInContext (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/newrelic/lib/context-manager/legacy-context-manager.js:59:23)\n at Axios.request (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/axios/dist/node/axios.cjs:3877:41)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", "config": { "transitional": { "silentJSONParsing": true, "forcedJSONParsing": true, "clarifyTimeoutError": false }, "adapter": [ "xhr", "http" ], "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "maxBodyLength": -1, "env": {},
vinman8866
vinman8866OP6mo ago
"headers": { "Accept": "application/json, text/plain, /", "Content-Type": "application/json", "User-Agent": "axios/1.6.7", "Content-Length": "68", "Accept-Encoding": "gzip, compress, deflate, br" }, "method": "post", "url": "https://hooks.slack.com/services/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", "data": "{"text":"A new post has been created","blocks":[{"type":"section"}]}" }, "code": "ERR_BAD_REQUEST", "status": 400 }
Slack API
Unlock your productivity potential with Slack Platform
Connect, simplify, and automate work.
vinman8866
vinman8866OP6mo ago
Here is the workflow:
import { workflow } from "@novu/framework";

export const euniceMonitorSlack = workflow(
"eunice-monitor",
async ({ step, payload }) => {
await step.chat(
"send-chat",
async () => {
return {
body: "A new post has been created",
};
},
{
providers: {
slack: ({ inputs }) => ({
text: "A new post has been created",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "A new post has been created",
},
},
],
}),
},
}
);
}
);
import { workflow } from "@novu/framework";

export const euniceMonitorSlack = workflow(
"eunice-monitor",
async ({ step, payload }) => {
await step.chat(
"send-chat",
async () => {
return {
body: "A new post has been created",
};
},
{
providers: {
slack: ({ inputs }) => ({
text: "A new post has been created",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "A new post has been created",
},
},
],
}),
},
}
);
}
);
Just as a note @Pawan Jain - the slack provider etc. was working with the original novu cloud setup. It has stopped working now trying to implement the workflow in novu echo. thank you for your help
Pawan Jain
Pawan Jain6mo ago
@vinman8866 I am debugging the issue
vinman8866
vinman8866OP6mo ago
Thank you Hi @Pawan Jain - any update on this? I also have another issue where using the original cloud framework with a payload - I am seeing "=" in a URL be encoded to "=" i can see this is happening when i run my trigger programatically or via the trigger notification in the cloud UI. is this happening in Novu or in Slack? an example URL and it's conversion is: https://myapp.com/dashboard/events?event=611399accdb30ba8f48ea2ff1912c633 https://myapp.com/dashboard/events?event=611399accdb30ba8f48ea2ff1912c633
Novu_Bot
Novu_Bot6mo ago
@vinman8866, you just advanced to level 2!
vinman8866
vinman8866OP6mo ago
don't worry about the URL encoding issue - i've managed to resolve it by finding another post in the support channel
Want results from more Discord servers?
Add your server