Skip to main content

Today's date

I see that there is a planned feature to get today's date into the AI. I needed that so I thought I'll share what I did yesterday.

1) I wrote a 5 line PHP script and called it todaysdate.php and saved it on my HTTP server. (See the end of this post for the source code.)

2) In the Chatling builder, I called an HTTP Integration and connected to it from the start node. On the HTTP request I typed: https://example.com/todaysdate.php. (use your own address). I used GET, but I don't think that's important.

Under Save response, I received a response called todaysdate and created a Chatling variable called {todaysdate}.

3) Under Chatling instructions, I created an instruction "Today's date is {todaysdate}" (using the variable I had created).

4) If you save and publish the bot and ask it: What is today's date? it will dynamically give you the date.

NB Make sure your connectors are set up properly, ie Start to HTTP Integration to the rest of the AI flow.

This is the PHP source code I wrote: (disclaimer - I asked ChatGPT for the code)

<?php

// Get today's date and format it

$todaysdate = date("j F Y");

// Create an associative array with the parameters

$response = array( 'todaysdate' => $todaysdate);

// Convert the array to JSON format

$json_response = json_encode($response);

// Set the content type header to JSON

header('Content-Type: application/json');

// Output the JSON response

echo $json_response;

?>

I hope this is going to help someone.

1 comment

Log in to comment and vote

Comments1

  • Ali Mahdi

    Team•

    Mar 20, 2024

    Great tip, thanks for sharing!