Good (morning|afternoon|evening),

With the initiate functionality, you can choose to put one of two restrictions based on the targeted user:

·         The user has to be known to the agent

·         The user has to actually be conversing with the agent

This is a good idea to set those restrictions to avoid spamming the users.

By checking the result of initiate, you can know if it succeeded or not. If it did not, depending on the restrictions you just put, you can conclude if the user is known to the agent or if the user is not currently talking to the agent. You set those restrictions by adding the following properties:

·         {createprofile=false}: initiate will fail if the user doesn’t have a profile yet.

·         {loadprofile=false}: initiate will fail if the user is not in session with the agent.

The result of initiate is an object, the two important members of that object are:

·         Delivered: contains 1 if delivered, 0 otherwise

·         Status: string indicating the reason it was not delivered.

Here is an example of use of that information, I call it “Do you know my friend?”

// Do you know my friend

procedure DoNothing()

  nop

? Do you know EMAIL=AnEMailAddress ?

  RESULT_NOLOAD = initiate EMAIL, "MSN": DoNothing() {createprofile=false loadprofile=false}

  if RESULT_NOLOAD.Delivered

    - Yes I do, and he/she's talking to me right now.

  else

    RESULT_LOAD = initiate EMAIL, "MSN": DoNothing() {createprofile=false loadprofile=true}

    if RESULT_LOAD.Delivered

      - Yes, I know that guy

    else

      - Sorry, I can't say that I do

Another use of initiate is to send information from one user to another user. The next example is “Leave a note to my friend”. It lets a user leave a message for another user, which will get the message the next time he/she talks to the agent.

In addition, this example checks to see if the user is currently in session, in which case it will deliver the message immediately.

// Leave a note to my friend

declare procedure SendMessageDirectly(FRIEND_NAME, MESSAGE)

declare procedure LeaveMessageNote(FRIEND_NAME, MESSAGE)

? Can I leave a note to EMAIL=AnEMailAddress ?

  - Sure, what's the message ?

  ? MESSAGE=AnythingRaw

    RESULT = initiate EMAIL, "MSN": SendMessageDirectly(SYS.User.NickName, MESSAGE) {createprofile=false loadprofile=false}

    if RESULT.Delivered

      - Well, your friend and I are actually talking to each other right now, so I'm telling him/her now.

    else

      RESULT = initiate EMAIL, "MSN": LeaveMessageNote(SYS.User.NickName, MESSAGE) {createprofile=false loadprofile=true}

      - Ok, I'll leave a note for him/her to read next time he/she talks to me

procedure SendMessageDirectly(FRIEND_NAME, MESSAGE)

  - Hey, your friend FRIEND_NAME has left a message for you:

    MESSAGE

 

stored variable OFFLINE_MESSAGE_FROM_FRIEND = ()

 

procedure LeaveMessageNote(FRIEND_NAME, MESSAGE)

  OFFLINE_MESSAGE_FROM_FRIEND.FriendName = FRIEND_NAME

  OFFLINE_MESSAGE_FROM_FRIEND.Message = MESSAGE

 

procedure overrides ABGreetingProc(USERARRIVES, NEWUSER)

  - Good day!

  if OFFLINE_MESSAGE_FROM_FRIEND != ()

    - Hey, your friend OFFLINE_MESSAGE_FROM_FRIEND.FriendName left the following message for you:

      OFFLINE_MESSAGE_FROM_FRIEND.Message

    OFFLINE_MESSAGE_FROM_FRIEND = ()

   

About notifications, the only thing there is to do is to cancel them before they trigger. This is done by saving the notification id and passing it to the “cancel notify” statement.

To illustrate this simple thing, here’s the previous Kitchen timer example improved with a stop functionality.

// Kitchen Timer stopper

declare procedure Ring()

variable KITCHEN_TIMER_NOTIFICATION = ""

? Kitchen timer

  - Ok, I'm setting up the time, how many minutes do you want ?

  ? DELAY=Integer

    - Alright, I will notify you in DELAY minutes

    KITCHEN_TIMER_NOTIFICATION = notify in DELAY minutes: Ring()

? Cancel Kitchen timer

  if KITCHEN_TIMER_NOTIFICATION = ""

    - What timer ?

  else

    cancel notify KITCHEN_TIMER_NOTIFICATION

    KITCHEN_TIMER_NOTIFICATION = ""

    - Done.

   

procedure Ring()

  - DRRRRRRRING !!!!!

    Your time is up!

  KITCHEN_TIMER_NOTIFICATION = ""

Those messages, coming from an initiate or a notification, are designed not to disrupt the conversation. What that means is if the user is expected to answer a dialog or an enumeration, the fact that his kitchen timer rings or that he receives a message from a friend won’t prevent him from answering as he was supposed to.

What that also means is, if you add a dialog to your Ring procedure, the user will most likely not be able to answer it. How to fix this? This will be explained in the next post.

Damien.