1. Webchat Template
  2. Create Context

Webchat Template

Create Context

Explains Webchat create context setup for initial connections. Useful for starting new stubs or onboarding users from Webchat sessions.

The create context receives the first message from a webchat user and initializes a new conversation stub.

What is the Create Context Used For?

  • Interacting with end users through webchat requires a stub that manages incoming traffic
  • The create context specifies actions that handle the first message a user sends from webchat
  • The create context creates a stub that handles webchat events

Setup Options

You have two routing options for your webchat traffic:

  1. Navigate to the create context and open the canvas

  2. Create an action called _update_from_webchat

    Your canvas should look like this:

  3. Configure Create Stub Task

    In the _update_from_webchat action, add the task create_stub (with data) from the task library:

    Configure with the following parameters:

            "params": {
      "templateuuid": "~~template.templateuuid",
      "template_branch": "~~template.branch",
      "template_context": "default",
      "data": {
        "_incoming_webchat_data": "~~stubpost.data._incoming_webchat_data"
      }
    }
    
          

    Data from the webchat service is placed in stub.data._incoming_webchat_data. To pass it to the new stub, set params.data._incoming_webchat_data to ~~stubpost.data._incoming_webchat_data.

  4. Test Your Webchat Client

    • You will see that a draft stub was automatically created for you

    • Open that stub and copy the stubref

    • In your webchat profile, select the draft branch and enable Send webchat traffic to stub

    • Paste your copied stubref into the stubref field

    • Open your webchat client and send a message

    • The webchat service then executes the _update_from_webchat action

Option 2: Heimdall Routing (For Advanced Use Cases)

  1. Navigate to the create context and create an action register_heimdall_paths

    Your canvas should look like this when complete:

  2. Configure Heimdall Register Task

    In register_heimdall_paths, add the task heimdall_register from the task library:

    Configure with the following parameters:

            "params": {
      "uuid": "{{#deterministicuuid stub.stubref stub.program.branch 'initial'}}{{/deterministicuuid}}",
      "registration_name": "heimdall_webchat_initial_message",
      "on_trigger_method": "keep",
      "events": {
        "webchat_initial_message": {
          "path": "stubber.systems.notifications.webchat.org.{{stub.orguuid}}.name.{{stub.program.branch}}_your_chat_name.webchatmessagetype.firstmessage",
          "mechanism": "cbh",
          "timeout_seconds": 3600
        }
      },
      "trigger_stubaction": {
        "action_name": "create_stub",
        "stubref": "~~stub.stubref",
        "message": "Created stub from webchat"
      }
    }
    
          

    Important: Replace your_chat_name with the Chat name from your webchat profile.

  3. Configure Create_Stub Action

    In create_stub, add the task create_stub (with data) from the task library:

    Configure with the following parameters:

            "params": {
      "templateuuid": "~~template.templateuuid",
      "template_branch": "~~template.branch",
      "template_context": "default",
      "data": {
        "_incoming_webchat_data": "~~stubpost.data.heimdall.webchat"
      }
    }
    
          

    Data from heimdall events is placed in stub.data.heimdall.webchat. Pass it to the new stub; it contains the webchat session uuid used to reply to a specific webchat instance.

  4. Test Your Webchat with Heimdall

    • Create a draft stub and run the action register_heimdall_paths

    • Open your webchat client and send a message

    • Heimdall then executes the create_stub action