Get Date - CodelessBot

What Does This Plugin Do?

BETA
This plugin will send back the date for a specific timezone.

Level of Difficulty: Easy-Medium

Compatibility: Chatfuel, ManyChat

Plugin Request URL
  • Chatfuel: https://api.codelessbot.com/v1/chatfuel/datetime/current-date?accesskey={{cbot_accesskey}}&secretkey={{cbot_secretkey}}
  • ManyChat: https://api.codelessbot.com/v1/manychat/datetime/current-date?accesskey=YOURACCESSKEY&secretkey=YOURACCESSKEY

Example Use Cases

Daily Special

Determine the day of the week to send user’s your restaurant’s daily special

}

Hours of Operation

Find out the current day of the week to let customers know if you’re opened today!

How-To Setup the Plugin

Follow the 3 Simple Steps...or Login to CodelessBot to access the Plugin Wizard!

Step 1. Download & Install the Quick-Start Plugin Template

Login to CodelessBot, navigate to Templates on the sidebar and download the Quick-Start Template. Follow the prompt to install the Template. Next, you'll need to create a copy of the template for this specific plugin. See and follow the instructions below.

(If you've already install the Quick Start Template and created a copy of the plugin template - skip this step!

Chatfuel Instructions

a. From your Chatfuel dashboard, open the new bot called "JSON API Tutorial & CodelessBot Template" 

b. Find the group containing the name of this plugin.

c. Click on the arrow next to the plugin name to clone this group and blocks from the template into your own Chatfuel Bot.

d. Navigate back to the Chatfuel Dashboard

e. Open your Bot and find the new plugin group that you just cloned. 

f. Open the new Plugin block and enter in your CodelessBot access key and secret key.

Tip: Rename the plugin block to something more meaningful. For more details, refer to the Getting Started Guide.

ManyChat Instructions

After you download and installed the Quick Start Template...

  1. From the ManyChat sidebar, click on the Flows"
  2. Open the folder "CodelessBot Templates"
  3. Find the flow containing the name of this plugin. 
  4. Create a copy by click on the three dots icon on the right
  5. Then click on duplicate
  6. Feel free to rename this new flow and move it to a different folder
  7. Open up the flow and click on the "Starting Step" to modify the information you'll be sending to CodelessBot

For more details, refer to the Getting Started Guide.

Step 2. Send information to CodelessBot

To quickly do this, use the Plugin Wizard to answer a few questions. It'll then generate the code with the information below for you to copy and paste into your bot.

cbot_timezone (Option 1)

A specific timezone from the list of IANA timezones.

More Detail

You’ll need to send CodelessBot the IANA timezone. Which can be found on Wikipedia at http://bit.ly/cbtimezone. Use the values from column TZ. Example values are Africa/Abidjan, America/New_York, Europe/London.

timezone (Option 2)

The user’s timezone as set by the bot platform.

More Detail

You’ll need to send CodelessBot the user’s timezone. For Chatfuel, you can use the system attribute “timezone”.
For ManyChat, you’ll need to send the timezone custom field.

Chatfuel Instructions
  1. In this plugin block, scroll down to the "JSON API" card
  2. Copy and paste the code from the Plugin Wizard into the textbox. (Or you can enter the correct value by referring to the descriptions above.)

Tip: Make sure the "Send as" is set to JSON. Not URL encoded or Full JSON Profile.

ManyChat Instructions

a. Click over to the "Body" tab in this external request 

b. Next, copy and paste the code from the Plugin Wizard into the "Request Body". (Or you can enter the correct value by referring to the descriptions above.)

c. If there are any "Replace With placeholder" in the code, you'll need to replace them with the correct matching custom field by clicking on "Add a Variable".

d. To check if you set this up correctly, click on "Test the Request" on the right and you should get a success "200 OK" response

e. Click on the blue "Save" button

Step 3. CodelessBot will reply with the "answer"

CodelessBot will reply back with the following information:

cbot_rsp

A text representation of the full date.

More Detail

e.g. January 1, 2019

cbot_rsp_dow_long

The day of the week (Full name format – e.g. Sunday)

cbot_rsp_day

A numeric value from 1 to 31 representing the day of the month.

cbot_rsp_month_long

The current month (Full name format)

More Detail

e.g. January, February, March, April, May, June, July, August, September, October, November, December

cbot_rsp_dow_short

The day of the week (abbreviated format)

More Detail

e.g. Sun, Mon, Tue, Wed, Thu, Fri, Sat

cbot_rsp_month

A numeric value from 1 to 12 representing the month.

cbot_rsp_year

The current year (represented in a numeric 4 digit value)

cbot_rsp_month_short

The current month (abbreviated format)

More Detail

e.g. Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

Chatfuel Instructions

After the JSON API card, you can add additional Chatfuel cards to:

  1. Send a message to the user with the result
  2. Add a new card "Go To Block" with a condition to redirect users to a different blocks depending on the result

Note: These are just some ideas. You are not limited by the 2 ideas above.

ManyChat Instructions

Finally, to save and make use of the results, you'll need to save the answer(s) from the CodelessBot to ManyChat custom field(s). To do this:

a. Click over to the "Response mapping" tab.

b. All the answer(s) are already listed for you under the first column "JSONPath". (For more detail about each one, see description above).

For each answer, select the ManyChat custom field you want to use to store the value from CodelessBot. Feel free to delete any that you don't need.

c. Click on "Save" when you're done. After this external request step, you can add a next step where you're:

  • Sending a message to share the results with users
  • Add a new Condition step to redirect users to a different step or flow depending on the result

More Information

FAQs

1. What happens if I send both cbot_timezone and timezone parameters?

The timezone value will take precedence and cbot_timezone will be ignored.

2. When would I use cbot_timezone as opposed to timezone?

It depends. Do you want to:

  • obtain the current time for a known, specific timezone? or
  • obtain the current time for the user that’s currently chatting with your bot?

Here’s two examples:

  • If you want to get the current time for a restaurant located in New York, you would set cbot_timezone.
  • If you want to get the current time to tell a user it’s their lunch time, then you would use timezone.

The actual value of timezone and it’s accuracy will depend on the user’s settings in Facebook.

3. Where can I get a full list of all values that can be used for cbot_timezone and are they case sensitive?

You can find a list on Wikipedia (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) and other Internet resources. Examples would include America/New_York or Europe/London.
There is no case-sensitivity. America/New_York is the same as america/new_york

4. What languages or locales are supported?

Only US English is supported. All text values will be returned with spellings and abbreviations that are appropriate for US English.

5. How accurate is this plugin?

The plugin using IANA timezone (Option 1) will always be accurate.

The accuracy of User timezone (Option 2) will depend on the information provided by Chatfuel/ManyChat.

Whenever possible, we strongly recommend that you use an IANA timezone (Option 1).

Enhance Your Bot with CodelessBot

CodelessBot plans start from $18/month