I have an individual account and have successfully launched a workflow from a webhook trigger. However, the response I get from the POST command is empty. I have tested the POST command using POSTMAN and the status code is 204 (no content). The request log shows that workflow completed successfully. If I add an ‘Send Email’ block, that works. But the ‘End Session’ block doesn’t send anything. (My End Session block specifies JSON output with the same variable that worked in the ‘Send Email’ block.) What am I missing here? Thanks.
Hi @pj16,
Thanks for the post!
The Webhook trigger lets you launch the Agent, but it isn’t designed to return output. If you need the Agent to process data and return a response to Postman, please set the Start block to the On-demand trigger and call the Agent via the API:
You can also find the Raw Fetch Code for each Agent under the API tab:
Hope this helps!
Thanks very much, Alex. The configuration page for the End Session block says that it returns JSON output. I assumed that it would return it as the response to the POST command. I understand now that there is no response to the POST command. Thanks for the suggestion to use the API. My workaround for this issue was different since I am not integrating this workflow with an online server: I am calling it from RStudio. My workaround is to save the result in the longtext field of a MySQL database table. That part is working. Thanks again for the quick response. Peter
In case someone else wants to know the workaround, here is the function to save text variables in a MySQL database. It is important to use a prepared query because the text variable (ai.vars.jsdoc) has many special characters.
import mysql from 'mysql2/promise'; // Using the promise wrapper
async function runPreparedQuery() {
const connection = await mysql.createConnection({
host: ...,
user: ...,
password: ...,
database: ...
});
const sql = 'INSERT INTO msoutput (module, jstext) VALUES (?, ?)';
const moduledata = [ai.vars.modulename, ai.vars.jsdoc];
try {
// The 'execute' method handles the prepared statement automatically
const [results] = await connection.execute(sql, moduledata);
console.log('Module added with ID:', results.insertId);
// Reusing the connection to run a SELECT query
const selectSql = 'SELECT * FROM msoutput WHERE id = ?';
const moduleId = [results.insertId];
const [rows] = await connection.execute(selectSql, moduleId);
console.log(rows);
} catch (err) {
console.error(err);
} finally {
await connection.end();
}
}
export const handler = ()=>{
runPreparedQuery();
}
The database table DDL is as follows:
-- ....msoutput definition
CREATE TABLE `msoutput` (
`id` int NOT NULL AUTO_INCREMENT,
`module` varchar(100) DEFAULT NULL,
`jstext` longtext,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
