Pass dynamic input to OpenAI node

Hi, just started to try out n8n after using make for quite sometime and I’m hitting a roadblock here.
I’m getting a calendar app’s available times and wanted to pass the “slots” data as input to the openAI node but I can’t seem to figure it out. Any help would be appreciated!

Attaching screenshot below:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @rish404
could you share the entire workflow to get an idea of how that data is retrieved?

To write a prompt for Open AI you should convert your data into a string.
The first strategy I would try is something like {{ JSON.stringify($json.Aggregate.slots[0]) }} that converts the JSON into a string. Open AI should be good enough to understand what’s in there and do what you need

Let me know if that works

Thanks for you reply, @giulioandreini
I’m not able to still make it work. Attaching my workflow below

You’ll not be able to call the api without auth so here’s a sample data:

{"slots":[{"date":"2024-08-05","day":5,"slots":{"22:00-22:30":{"start_time":"10:00 PM","count":1,"end_time":"10:30 PM"},"22:30-23:00":{"start_time":"10:30 PM","count":1,"end_time":"11:00 PM"},"23:00-23:30":{"start_time":"11:00 PM","count":1,"end_time":"11:30 PM"},"23:30-00:00":{"start_time":"11:30 PM","count":1,"end_time":"12:00 AM"}}},{"date":"2024-08-06","day":6,"slots":{"00:00-00:30":{"start_time":"12:00 AM","count":1,"end_time":"12:30 AM"},"00:30-01:00":{"start_time":"12:30 AM","count":1,"end_time":"01:00 AM"},"01:00-01:30":{"start_time":"01:00 AM","count":1,"end_time":"01:30 AM"},"01:30-02:00":{"start_time":"01:30 AM","count":1,"end_time":"02:00 AM"},"22:00-22:30":{"start_time":"10:00 PM","count":1,"end_time":"10:30 PM"},"22:30-23:00":{"start_time":"10:30 PM","count":1,"end_time":"11:00 PM"},"23:00-23:30":{"start_time":"11:00 PM","count":1,"end_time":"11:30 PM"},"23:30-00:00":{"start_time":"11:30 PM","count":1,"end_time":"12:00 AM"}}},{"date":"2024-08-07","day":7,"slots":{"00:00-00:30":{"start_time":"12:00 AM","count":1,"end_time":"12:30 AM"},"00:30-01:00":{"start_time":"12:30 AM","count":1,"end_time":"01:00 AM"},"01:00-01:30":{"start_time":"01:00 AM","count":1,"end_time":"01:30 AM"},"01:30-02:00":{"start_time":"01:30 AM","count":1,"end_time":"02:00 AM"},"22:00-22:30":{"start_time":"10:00 PM","count":1,"end_time":"10:30 PM"},"22:30-23:00":{"start_time":"10:30 PM","count":1,"end_time":"11:00 PM"},"23:00-23:30":{"start_time":"11:00 PM","count":1,"end_time":"11:30 PM"},"23:30-00:00":{"start_time":"11:30 PM","count":1,"end_time":"12:00 AM"}}},{"date":"2024-08-08","day":8,"slots":{"00:00-00:30":{"start_time":"12:00 AM","count":1,"end_time":"12:30 AM"},"00:30-01:00":{"start_time":"12:30 AM","count":1,"end_time":"01:00 AM"},"01:00-01:30":{"start_time":"01:00 AM","count":1,"end_time":"01:30 AM"},"01:30-02:00":{"start_time":"01:30 AM","count":1,"end_time":"02:00 AM"},"22:00-22:30":{"start_time":"10:00 PM","count":1,"end_time":"10:30 PM"},"22:30-23:00":{"start_time":"10:30 PM","count":1,"end_time":"11:00 PM"},"23:00-23:30":{"start_time":"11:00 PM","count":1,"end_time":"11:30 PM"},"23:30-00:00":{"start_time":"11:30 PM","count":1,"end_time":"12:00 AM"}}},{"date":"2024-08-09","day":9,"slots":{"00:00-00:30":{"start_time":"12:00 AM","count":1,"end_time":"12:30 AM"},"00:30-01:00":{"start_time":"12:30 AM","count":1,"end_time":"01:00 AM"},"01:00-01:30":{"start_time":"01:00 AM","count":1,"end_time":"01:30 AM"},"01:30-02:00":{"start_time":"01:30 AM","count":1,"end_time":"02:00 AM"},"22:00-22:30":{"start_time":"10:00 PM","count":1,"end_time":"10:30 PM"},"23:30-00:00":{"start_time":"11:30 PM","count":1,"end_time":"12:00 AM"}}}]}

I want to extract only the “start_time” for a specific date, which will be supplied via a trigger webhook. In make.com, it’s failry simple but I’m not able to figure it out here

Hi @rish404
it actually worked on my side, here’s the workflow:

The edit fields node is just there to mock the data you passed me.
You also find a Code node that does the transformation using some js code.

Let me know if this helps

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.