How to let bot start the conversation

did you uncommented the below line in script.js?

Yeah…Uncommented those lines

can you share the screenshot of your browser console logs?

@Banu95 I tried to implement the same code as yours but I didn’t found any issues

actions.py

class ActionGreetUser(Action):
    """
    Greet user for the first time he has opened the bot windows
    """

    def name(self) -> Text:
        return "action_greet_user"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        
        dispatcher.utter_message("Welcome to Rasa Chat")
        return [UserUtteranceReverted()]![image|551x500]

Browser Output

are you using the latest version of the chatbot widget?

1 Like

i guess , i am using this version of widget GitHub - JiteshGaikwad/ChatbotWidget at 210f7922e19b7b9953fb2e5730f5f6f4d9c7fd1f . Will try with the new version and let you know

@JiteshGaikwad, I think I know what Banu95’s problem is. I may have the same problem.

The widget does not show the response when there is a template. For example, my starter action calls dispatcher.utter_message(template = t, buttons = b). The buttons correctly show at the start, but without text.

In customActionTrigger(), I added console.log(JSON.stringify(botResponse.responses)). This is what I got:

[{"text":null,
"buttons":[(Correct list of buttons)],
"elements":[],
"custom":{},
"template":null,
"image":null,
"attachment":null,
"response":"utter_greet_English"}]

So it correctly detected the template/response, but it is not printing it. This is expected since there is no if (Object.hasOwnProperty.call(response[i], "response")) in function setBotResponse()!

@ChrisRahme thanks for pointing out the issue, I guess the template will be deprecated starting v3.0, so I haven’t added support for the same

1 Like

I actually use response instead of template. And your widget is correctly detecting the response’s name.

But now, how can we add to your code? Because if we do as below, it will just print the name of the response (obviously). Is it possible to get the text from the response? Because it doesn’t look like it.

if (Object.hasOwnProperty.call(response[i], "response")) { // Response contains "response"
  if (response[i].response != null) {
    var formatted_text = response[i].response // Only gets response name instead of text
    const BotResponse = `
      <img class="botAvatar" src="${botPic}"/>
      <p class="botMsg">${formatted_text}</p>
      <div class="clearfix"></div>`;
    $(BotResponse).appendTo(".chats").hide().fadeIn(1000);
  }
}

I tried the new version of the ChatBot Widget, its working now. Thanks for your support @JiteshGaikwad.

1 Like

@ChrisRahme I don’t think so you need to check for the response key as the response only contains the following keys

  • text
  • buttons
  • custom
  • image
1 Like

Yeah that’s true… But why istext null when I use utter_message(response = ...)?

[{"text":null,
"buttons":(Correct list of buttons),
"elements":[],
"custom":{},
"template":null,
"image":null,
"attachment":null,
"response":"utter_greet_English"}]

can you tell me where in the docs we have utter_message(response = ...) :thinking: ?

1 Like

Isn’t template deprecated in favor of response?

yes it’s, I told you already

1 Like

Yes exactly, so this is why I use utter_message(response = ...)

that’s what I’m asking you can you tell me where is it in the docs?

1 Like

Ok okay, sorry. It’s here.

Okay got it, so if you have static response defined in your domain.yml file and you want to use that response in actions.py i.e your custom actions you can do it using the response keyword for e.g. utter_greet_name in domain.yml

responses:
  utter_greet_name:
  - text: Hi {name}!

can be used as below in custom actions

dispatcher.utter_message(response = "utter_greet_name", name = "Aimee")
1 Like

But that’s what I’m doing haha. I don’t know why it’s not working.

Anyway, I’m having a lot of problems since 2.4 (here), I downgraded to 2.3 and went back to using template and it works. Unless it’s for the first message, in which case the text does not show up: image