Putting a variable into daily.co json

So I’m trying to link daily.co with n8n to create a new room (with a random name) and an owner token.
I’ve got a “http request” running which creates the room and outputs the name and URL etc. I’m then linking that to another “http request” which creates a new token for that room.

The issue I’m having is the variable isn’t inputting into the json, the expression I have is here which sends successfully to daily.co.

{{'{"properties":{"room_name":"{{$json.name}}","is_owner":"true"}}'}}

The output at daily.co looks like this…
CleanShot - TQlXyRCb

You can see the variable name is being passed not the actual value from the previous “http request”.

I think I’ve sanitised this enough, please let me know if I haven’t!

Hi @litecactus, I am sorry you’re having trouble.

This doesn’t look like a valid expression to me, so tbh I am surprised you could send this in the first place. The problem here will be that n8n considers the first occurence of }} to be the end of your expression, treating everything afterwards like a string.

If you want to send a valid JSON object with a properties field (which itself is a JSON object with properties such as room_name and is_owner) you could do this instead:

By handling this as a JS object you can avoid having to build a suitable string yourself with a mix of expression and non-expressions parts in the same field. You can see in n8n’s expression preview how the room_name field is populated as expected:

image

This is also the data arriving on your server:

Hope this helps!

Thank you so much for your reply. It has led me to a solution although not necessarily what you suggested!

I think Daily is wanting very specific json so this actually ended up being the solution…

{{'{"properties":{"room_name":"'}}{{ $json.name }}{{ '","is_owner":"true"}}'}}

The first {{' opens the json so I figured what if I close the json with a '}} after the "room_name":" then insert the $json.name variable then open the json again with the {{' and finish the syntax then close it again! Bam, working! :+1:

3 Likes

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