3

In working with IBM Watson Conversation Service (WCS) I want to print an email address in the response. The problem is that WCS is neglecting all the characters after @ symbol and the @ character itself.

I tried using ' and \ to escape it, but it didn't help much.

How can I print an email address in a response string?

data_henrik
  • 16,724
  • 2
  • 28
  • 49
Narasimha Maiya
  • 1,009
  • 4
  • 12
  • 35

4 Answers4

7

If the email address is passed into the Watson Conversation service as a context variable, then it can be returned (printed) as part of the response string. Assuming the variable is named "email" and its value is "henrik@example.com", the following would do as response:

Hello, your mail address is <? $email ?>

It would return:

Hello, your mail address is henrik@example.com

However, you need to be careful if you want to print out special characters such as @. The reason is that it refers to entities. It is a shorthand. In that case you need to escape that sign with \, e.g., \@. Here is a hardcoded response:

Please contact support at support\@example.com
data_henrik
  • 16,724
  • 2
  • 28
  • 49
1

I'm not sure about your question, but, if you want to return the mail address inside the conversation, you can add the mail address value inside the context variable [advanced response]:

{
  "context": {
    "mail": "mail@domain.com"
  },
  "output": {
    "text": {
      "values": [
        "Your mail address is $mail"
      ],
      "selection_policy": "sequential"
    }
  }
}

And use $mail[method for access contexts variables] for access this value and return in your conversation something like:

if bot recognizes yourCondition response "Your mail address is $mail

But, if you want to use some custom code for that, you can add the return from your Conversation message call, something like:

//add inside your call, like:
conversation.message(payload, function (err, data) {
    data.context.mail= "mail@domain.com";
    if (err) {
      return res.status(err.code || 500).json(err);
    }
    updateMessage(payload, data, req, res);

  });
}); 

And in your Watson Conversation Service, you can use this variable inside every response message with $mail.

Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
1

This is the same problem. I had faced it. and the solution is very pretty simple.

if you are using watson assistant UI try in response like,

youremail\@gmail.com

it will work, if you are using watson assistant API to manipulate the dialog. you have to give

"youremail\\@gmail.com"

I don't know the reason for that. but, the solution seems to work.

Arun Karikalan
  • 132
  • 1
  • 5
0

If you need to write a static email address, you might have to hack it. It seems like WCS assumes you know what you're doing if you add a (dummy) variable in the response.

ex: Email addr@gmail.com!

results in: Email addr! (text)

but: Email addr@gmail.com! <? $x >

results in: Email addr@gmail.com! (link)

the former is just the literal 'addr'

the latter is the link: (addr@gmail.com) < a href="mailto:addr@gmail.com" class="WAC__Link WAC__Link-email" target="_blank" rel="noopener noreferrer" > addr@gmail.com < / a >