Invoke Agent Payload

Hello all

I have found a couple of posts of the json payload needed in a workflow in order to invoke an agent but this payload only includes text content and I also need to send a file in base64 format. I have seen something like this in another post

{
"messages": [
{
"role": "user",
"content": [ { type: "text", text: {{ code1.data.message }} },
{ type: "document", filename: {{ workflow1.data.name }}, file_data: {{ code1.data.attach }} }]
}
],
"action": "invoke"
}

but I get an error that the content should be a string and not an array.

Any help would be appreciated.

Hey @hrisafis

Thank you for reaching out to the Retool community.

You should be able to send these information to a Workflow, no problem. What I think might be happening here is your JSON is not formatted completely. All JSON keys need to be in double quotes — type, text, filename, and file_data were missing them.

I went ahead and remade it for you to try and copy and paste and see if this fixes it.

{
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": {{ code1.data.message }} },
{ "type": "document", "filename": {{ workflow1.data.name }}, "file_data": {{ code1.data.attach}} } ]
}
],
"action": "invoke"
}

I would recommend checking your JSON in the IDE of Retool as it should mention if its in Object format in the send to the Workflow Resource.

You could also use an online JSON checker to make sure its all correct too.

Let me know if this helps resolve it or you are facing a different issue.

Regards,
John | Retool Support

Thank you for your reply. I actually got the solution from another community member MiguelOrtiz, the issue was that I had to stringify the content property.

1 Like