1. Guides
  2. Webchat

Guides

Webchat

Setting up the webchat notification system

Setup webchat template

Create a template from scratch

Name the template Webchat Guide

Create context

Navigate to create context and click on Edit Flow image

Adding actions

Use the library to add the following actions :

  • Register for new webchat sessions
  • Send opening webchat message on create context
  • Opens a conversation on new webchat response

image

Configuring added actions

  • When creating a new webchat it is important to give it a UNIQUE NAME
  • This name will be used for routing client packets to this stub

image

  • The name must be all lowercase and have no spaces or special characters
  • In the path below your name will be placed in .{{stub.program.branch}}yourcustomname.
  • e.g .{{stub.program.branch}}mywebchat.
  • New heimdall path will be : stubber.systems.notifications.webchat.org.{{stub.orguuid}}.name.{{stub.program.branch}}mywebchat.webchatmessagetype.initialize

Configuring template data

  • Add a welcome message via template data
  • Enter a message of your choosing

image image image

Register paths

  • Create a draft stub
  • Run action register_for_initial_chat_messages

image image

Configure webchat

Now that we have a stub listening for initialize events we can setup the webchat client

  • Get your orguuid

  • Open the webchat demo builder

  • Replace the orguuid field with your orguuid

  • Replace the chat_name field with draft + your webchat name

image

  • Click on refresh changes
  • Open the chat window

You should see the following message :

image

  • In your draft stub.data will be the webchat client details and sessionuuid
  • The sessionuuid will be used to send payloads to a specific webchat session

image

  • Once a user sends a message a new stub will be created on the default context to handle the conversation

image

Default context

Navigate to default context and click on Edit Flow

  • Add actions _create , _update_from_webchat
  • _create action executes on stub creation. This action will be used to initialize the conversation
  • _update_from_webchat action is executed but the stubber system when a new message is sent from the client

image

  • In _create action add the notification item Webchat notification to session

image

  • In the notification update sessionuuid and webchat_message.value as seen below
        "platforms": {
  "webchat": {
    "sessionuuid": "~~stub.data.webchat_sessionuuid",
    "webchat_message": {
      "type": "markdown",
      "value": "This is a message from create action"
    },
    "stubsession": {
      "set_new_with_timeout_hours": 24 // configures session to be 24 hours
    }
  }
}

      
  • Now your webchat will reply to you with This is a message from create action

image

  • This message will create a link between the webchat session and this stub session for 24 hours
  • All payloads will now be sent to this stub
  • Messages will be automatically placed in stubpost.message

image

  • To respond to further messages add the notification item Webchat notification to session to _update_from_webchat
  • configure the notification as seen below
        "platforms": {
  "webchat": {
    "sessionuuid": "~~stub.data.webchat_sessionuuid",
    "webchat_message": {
      "type": "markdown",
      "value": "This is a message from update_from_webchat action"
    },
    "stubsession": {
      "set_new_with_timeout_hours": 24
    }
  }
}

      
  • Now all future messages from this stubsession will be handled by this stub

image