Example link: https://creator.celestory.io/project/EXs9_365N

Importing your code allows you as developer to create your own Celestory block.

1.Create a ⬛ Run Javascript

This allows you to:

- create incoming trigger points

- create outgoing value points

2. Import your JS code

The editor of the block ⬛ Run Javascript contains a field to insert your JS code.

In this example of JS code using a β›… weather service:

const city = celestoryPoints.get('city', 'Paris');

const location = await fetch(`https://cors-anywhere.herokuapp.com/https://www.metaweather.com/api/location/search?query=${city}`);const locationData = await location.json();
if (locationData && locationData[0] && locationData[0].woeid) { const woeid = locationData[0].woeid; const weather = await fetch(`https://cors-anywhere.herokuapp.com/https://www.metaweather.com/api/location/${woeid}`); const weatherData = await weather.json();
if (weatherData && weatherData.consolidated_weather && weatherData.consolidated_weather.length > 0) { celestoryPoints.set('city', city); celestoryPoints.set('weather', weatherData.consolidated_weather[0].weather_state_name); celestoryPoints.set('temperature', weatherData.consolidated_weather[0].the_temp);
return; }}
celestoryPoints.set('city', city);celestoryPoints.set('weather', 'NOT_FOUND');celestoryPoints.set('temperature', 'NOT_FOUND');

3. Connect your bloc

- the incoming trigger point "city" down at left can be linked to a text variable from a Text Input or a user choice. So if the value of this text variable corresponds to a city of the service, this one will be recognized and the corresponding values will be synchronized. This incoming point is not mandatory, and by default the city is assigned in the the code JS in Paris.

- the outgoing value points in the bottom right-hand corner "city", "weather", "temperature" allows you to go foreign service search targets information corresponding to the selected city to transform them into the value that it is then

possible to assign to a variable in the graph.

To send your datas to other services, see: Connect your data with πŸ”Œ Zapier or πŸ”Œ Integromat

Did this answer your question?