Skip to main content
Skip table of contents

Date/Time Based Continuation

Introduction

In the example below, we assess the current day and hour to see if the message arrived during business hours. This can be particularly useful when you want to pass the conversation to an agent. If the message was sent outside of business hours, you can inform them of the next available contact time; otherwise, you can proceed with the handover.

YAML
config:  
  conversationOwner: null  
  conversationOwners:  
    - identifier: conversationOwner  
      channel: WhatsApp  
  scriptLanguageVersion: 1  
  scriptVersion: 1  
  defaultDelay: 200  
  lists:  
    positive-answers:  
      items:  
        - Ja  
    negative-answers:  
      source: negative-answers.yml

flows:  
  - id: main  
    description: Entry flow for the bot  
    steps:  
      - !entry  
        id: Entry-1  
        actions: []  
        clientActions: []  
        matches:  
          - opening  
        allowRestart: true  
        isCaseSensitive: true  
        doCatchAll: true      

      - !var  
        id: Save current time and day  
        actions: []  
        clientActions: []  
        set:  
          hour: $GetNow("Europe/Amsterdam", "HH")  
          dayOfWeek: $GetNow("Europe/Amsterdam", "dddd")  
          
      - !logic  
        id: 'Business hours: yes or no'  
        actions: []  
        clientActions: []  
        entries:  
          - condition: !and  
              conditions:  
                - !regex  
                    var: hour  
                    tests:  
                      - ^(0[8-9]|1[0-6])$  
                    isCaseSensitive: false  
                    
                - !regex  
                    var: dayOfWeek  
                    tests:  
                      - (Monday|Tuesday|Wednesday|Thursday|Friday)  
                    isCaseSensitive: false  
                    
            position:  
              cursor: inside business hours.Text-1  
              
          - condition: !default {}  
            position:  
              cursor: outside business hours.Text-1  

  - id: inside business hours  
    description: ''  
    steps:  
      - !text  
        id: Text-1  
        actions: []  
        clientActions: []  
        message: You have messaged us within our business hours.  

  - id: outside business hours  
    description: ''  
    steps:  
      - !text  
        id: Text-1  
        actions: []  
        clientActions: []  
        message: You have messaged us outside of our business hours.  

In here we use the $GetNow system functions as described in Variables.


Previous: examples Intro

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.