Zendesk Chat Advanced Details

The following code demonstrates how a "transfer to agent" flow might look in Zendesk Chat. There are a number of features particular to Zendesk Chat, which are explained below.

states:
    name:
        component: meya.input_string
        properties:
            text: "Name?"
            output: name
            scope: flow
    email:
        component: meya.input_string
        properties:
            text: "Email?"
            output: email
            scope: flow
    phone:
        component: meya.input_string
        properties:
            text: "Phone?"
            output: phone
            scope: flow
    transfer:
        component: human.transfer
        properties:
            text: Transferring you to an agent
            department: success
            note: This is a transfer note.
            timeout: 60
            timeout_flow: agent_timeout
            timeout_data:
                x: "X"
                y: "Y"
            chat_established:
                flow: chat_established_flow
                data:
                    established: "yes"
            chat_ended:
                flow: chat_ended_flow
                data:
                    ended: "yes"
            chat_transferred:
                flow: chat_transferred_flow
                data:
                    transferred: "yes"
            queue_update:
                flow: queue_update_flow
                data:
                    queue_update: "yes"
            connection_update:
                flow: connection_update_flow
                data:
                    queue_update: "yes"
            tags:
            	 - "spanish"
            visitor_details:
                name: "{{ flow.name }}"
                email: "{{ flow.email }}"
                phone: "{{ flow.phone }}"

If you've used another customer service integration, some of the human.transfer fields will look familiar.

FieldDescriptionNotes
textText to display to the user.Optional
departmentAssign the chat to an agent in this department.Optional
noteText to display only to the agent.Optional
timeoutIf an agent doesn't accept the conversation within this number of seconds, the flow specified by timeout_flow will be executed. If no timeout_flow is indicated, no flow will be executed.Optional
timeout_flowThe flow to execute if the agent doesn't respond to the conversation within the number of seconds specified by timeout.Optional
timeout_actionThe action to invoke when starting the timeout_flow.Optional Default: null
timeout_dataData to send to the timeout_flow.Optional
visitor_detailsA list of Zendesk Chat fields that will be updated.Optional

Assigning to a department

If no department is specified, the visitor will be sent to the Incoming Chats queue.

If a department is specified, but is busy, the visitor will enter the department queue.

If a department is specified, but is offline, the visitor will be sent to the Incoming Chats queue.

Callback flows

In addition to the above fields, a number of "callback" flows can be triggered based on certain events occurring in Zendesk Chat.

🚧

If you don't explicitly handle these events, nothing will happen. It's a good idea to handle them so your user knows what's going on.

FieldDescriptionNotes
chat_establishedThis flow will be triggered when an agent accepts the chat request.Optional
chat_transferredThis flow will be triggered every time the conversation is transferred to another agent.Optional
chat_endedThis flow will be triggered when the user or agent ends the conversation.Optional
queue_updateThis flow will be triggered every time the user's position in the queue changes.Optional
connection_updateThis flow will be triggered if the status of the conversation changes.

For example, if the conversation ends unexpectedly, this flow could offer to start a new conversation with an agent.
Optional

Each of these event handlers above has the following two fields.

FieldDescriptionNotes
flowThe flow to execute when the event occurs.Required for any callback event you want to handle.
dataData to pass to the flow.Optional

🚧

Bot pause/un-pause

In order to handle these callback flows, your bot will be automatically un-paused. At the end of each callback flow, remember to use the meya.pause component to pause the bot again, otherwise your use might see unexpected behaviour.

The exception to this is the chat_ended flow, which should not use meya.pause since the agent has handed the conversation back to the bot.

The five tabs in the code block below demonstrates what the five callback flows could look like.

states:
    first:
        component: meya.text
        properties:
            text: "You are now talking to {{ flow.agent_name }}."

    return_state:
        component: meya.pause
states:
    first_state:
        component: meya.text
        properties:
            text: "Transferring you to agent {{ flow.agent_name }}."

    return_state:
        component: meya.pause
states:
    text_state:
        component: meya.text
        properties:
            text: "The agent chat has ended."
states:
    check_position_state:
        component: meya.conditional_equal
        properties:
          value1: '{{ flow.queue_position }}'
          value2: 0
        transitions:
          equal: agent_queue_state
          notequal: main_queue_state

    main_queue_state:
        component: meya.text_buttons
        properties:
            text: "You are now in queue position {{ flow.queue_position }}"
            buttons:
                - text: "Continue Waiting"
                  action: continue
                - text: "Return to Bot"
                  action: return_to_bot
        transitions:
            continue: continue_waiting_state
            return_to_bot: return_to_bot_state

    agent_queue_state:
        component: meya.text_buttons
        properties:
            text: |
                You have been assigned to an agent but the agent still needs
                accept your chat.
            buttons:
                - text: "Continue Waiting"
                  action: continue
                - text: "Return to Bot"
                  action: return_to_bot
        transitions:
            continue: continue_waiting_state
            return_to_bot: return_to_bot_state

    continue_waiting_state:
        component: meya.pass

    return_from_continue_waiting_state:
        # Pause the bot again while we wait for an agent.
        component: meya.pause
        return: true

    return_to_bot_state:
        # Close the human.transfer session and let the bot takeover
        component: human.close
        return: true
states:
    check_position_state:
        component: meya.conditional_equal
        properties:
          value1: '{{ flow.status }}'
          value2: "closed"
        transitions:
          equal: connection_closed
          notequal: do_nothing
    connection_closed:
        component: meya.text_buttons
        properties:
            text: "Something went wrong connecting to our agents. Would you like to retry?"
            buttons:
                - text: "Retry"
                  flow: agent_flow
                - text: "No thanks"
                  action: continue
        transitions:
            continue: continue
    continue:
        component: meya.text
        properties:
            text: "OK. How can I help you then?"
        return: true
    do_nothing:
        component: meya.pause
        return: true

human.note

Using human.note, you can add a private message only agents can see.

states:
    leave_note:
        component: human.note
        properties:
            text: "They are a great customer! Treat them right."

human.close

You can end the conversation with the agent from within a flow by using the human.close component.

states:
    text_state:
        component: meya.text
        properties:
            text: "The ticket has been closed."

    close_state:
        component: human.close

meya.pause

If you're using any callback flows, the bot will be automatically un-paused so that it can execute the flow. At the end of each callback flow you must remember to use the meya.pause component to pause the bot again, otherwise the user may see unexpected behaviour.

❗️

Be careful with meya.pause!

meya.pause should only be used at the end of Zendesk Chat callback flows. Once the conversation ends, the bot will automatically un-pause. The only other way to un-pause the bot after meya.pause has been used is via API call.

Using meya.pause outside of a Zendesk Chat callback flow will result in the bot being permanently paused for that user, until you explicitly make an API call to un-pause it for that user.

Inactivity timeout

If no messages have been sent by the user for ten minutes, the chat will be automatically closed.