> For the complete documentation index, see [llms.txt](https://docs.chatlayer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/tutorials-1/using-time-in-your-chatbot.md).

# Using time in your chatbot

The Get Time plugin on our platform guides your flow based on the current moment in time.

## Implementation

To implement this, first create an Action bot dialog that contains a Get Time plugin.

Click on 'Get Time' and fill in your target (the name of this variable) and the offset.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MkvtY9kTViw2dBAWMIJ%2F-Mkw1J0a4W8lYLxCJaub%2Fimage.png?alt=media\&token=30449652-c02d-4e4b-b468-1963539beb46)

This plugin saves the current time variables to variable 'Target variable'. You can use it in your Go Tos and Bot Messages with the following variables:

* (target).utc.year
* (target).utc.month
* (target).utc.dayOfMonth
* (target).utc.dayOfWeek
* (target).utc.hours
* (target).utc.minutes
* (target).utc.seconds
* (target).utc.ISO

By default, the plugin result will contain some properties related to the UTC time.&#x20;

## Timezone

When you provide a `timezone offset` to the plugin, the result of the plugin will also contain time properties that are equal to UTC+\<OFFSET>.

* (target).offset.year
* (target).offset.month
* (target).offset.dayOfMonth
* (target).offset.dayOfWeek
* (target).offset.hours
* (target).offset.minutes
* (target).offset.seconds
* (target).offset.ISO

An example result for a time plugin with an offset of 8 hours on the October 6th, 2020 at 16:17 PM UTC was:

```javascript
{
    utc: {
      dayOfMonth: 6,
      dayOfWeek: 2,
      month: 10,
      year: 2020,
      hours: 16,
      minutes: 17,
      seconds: 44,
      ISO: '2020-10-06T16:17:44.727Z'
    },
    offset: {
      dayOfMonth: 7,
      dayOfWeek: 2,
      month: 10,
      year: 2020,
      hours: 2,
      minutes: 17,
      seconds: 44,
      ISO: '2020-10-07T02:17:44.727Z'
    }
}
```

All variables will return a number. You can use them in your flow like this:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MJ0Y57Pq6yNBAqj5usJ%2F-MJ0_IcwL--1r2tSZJZi%2FScreenshot%202020-10-07%20at%2007.42.33.png?alt=media\&token=07baf0df-72a5-457f-931b-913af048d7fa)

## Examples

Below you can find some examples on how to use time in your bot.

### Greeting

You can use the Get Time plugin to greet users in customized way, so 'good morning' and 'good afternoon'!&#x20;

First, change your introduction to a 'Go To'. Then, in that Go To, link to an Action dialog with the Get Time plugin. In that Action dialog, in the Go To section, link to a new Go To 'Check Time'. This Go To will look like this:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MlEXbD5db7oQAUlywec%2F-MlEYKVC8YPrJ4aDH8pL%2Fimage.png?alt=media\&token=638e5de7-9d5a-47aa-b693-d2e4234c6203)

In this Go To, the current hour is checked and divided into the evening, afternoon or morning through the different conditions. Depending on the current time, the variable {greetingTime} is dynamic, so you can have one introduction for the entire day.

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MlEXbD5db7oQAUlywec%2F-MlEcQHtGf2IE3420aNh%2Fimage.png?alt=media\&token=38e3e339-bc33-4266-ba9e-aa592aac4a11)

Where the complete flow will look like this:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-Mkw2GWG8OziiaxOoAkk%2F-Mkw8eZBKqIvE1dfRN4u%2Fimage.png?alt=media\&token=9a10e935-f298-4739-8db6-6a00c44b9766)

### Offloading

The Get Time plugin can also be used to check whether or not you would like to start offloading to a human agent. Create a similar flow as the one above, but instead of the routing to the introduction in the Go To, route to the Offloading Open or Offloading Closed bot dialog based on the time:

![](https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LLTwFwbOqJj4dDhg8Ju%2F-MlEXbD5db7oQAUlywec%2F-MlEd6XKD2roN7fGBted%2Fimage.png?alt=media\&token=21aa6f75-43fd-45de-bcda-b732616d6169)

In this case, the human agents are available from 9:00 (if the hour is greater than 8) until 16:00 (if the hour is lower than 16), and the Go To checks the time based on the previous Get Time plugin and will route the users correctly!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.chatlayer.ai/~/changes/zWOY8fNiBBrqneKkuGvA/tutorials-1/using-time-in-your-chatbot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
