Describe the problem/error/question
I have to beleive someone has run into this or has solved for something similar. Thanks for your help in advance.
I have been struggling to get Microsoft Teams Tool to post a chat to teams for approval workflow of content generated by an AI Agent. The approval flow works but I am blocked on this formatting. Without this, there is no app. Hoping someone out there has tried this with Teams. I can’t find any messages on this topic. I did see some folks talking about. PowerAutomate Approval flows which apparently are on the roadmap.
I do know that some of you have solved this via gmail email, but I need this to work in the Microsoft eco-system for what I am doing.
The things I have tried that does not work.
-
Used a Structured Output Parse to manually parse the contents of the AI generated email. This works just fine, but the agent is unable to pass the output of the structured output parser to the Teams Tool. I have tried prompting, but will continue to work on this.
-
Tried use Java Script code node to remove all \n and \n\n characters in the email body. I can see this work locally, but my prompt is failing to use this to post to Teams Tools
Here is the code:
-
// The ‘item’ variable gives you direct access to the current item’s data
const bodyText = $input.first().json.output[0].body// Replace all single newlines with a single newline and a space, and double newlines with a single newline.
// This is to handle potential inconsistencies from the AI.
const cleanedText = bodyText.replace(/\n\n/g, ‘\n’).replace(/\n/g, ‘\n’);// Create a new item with the cleaned body text.
return [{ json: { cleanedBody: cleanedText } }]; -
Tried a Coding Tool - no luck.
What is the error message (if any)?
The chat message comes through, however it’s ill formatted for human readability with no line feeds or new lines. It’s all one long sentence. See example below.
Please share your workflow
Share the output returned by the last node
example below snipped ** New Lead Alert** * Ney * The above lead with email [email protected] has company size of 54. ** AI Observations ** This is a medium-quality lead based on the company size of 54 employees. The email address “[email protected]” does not appear to be a legitimate business email, which might indicate a lower quality lead or a test submission. The call to action for this lead would be to follow up and verify the contact information and their interest. ** Response Draft ** Subject: Thank You for Your Interest, Nelly! Hi Nelly, Thank you for reaching out to us! We appreciate your interest in our services. We’ve received your information and are excited to learn more about your needs. A member of our team will be in touch shortly to discuss how we can help your company. In the meantime, if you have any immediate questions, please don’t hesitate to reply to this email. Best regards, The [Your Company Name] Team
Information on your n8n setup
- n8n version: Hosted n8n Version 1.108.2
- Database (default: SQLite): PostGres
- n8n EXECUTIONS_PROCESS setting (default: own, main): default
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker in Azure
- Operating system: Debian