diff --git a/docs/docs/reaching-out-to-user.mdx b/docs/docs/reaching-out-to-user.mdx index 375afd1783c9..3057423fc012 100644 --- a/docs/docs/reaching-out-to-user.mdx +++ b/docs/docs/reaching-out-to-user.mdx @@ -2,68 +2,59 @@ id: reaching-out-to-user sidebar_label: Reaching Out to the User title: Reaching Out to the User +abstract: Sometimes you want your assistant to reach out to the user without the user's prompting. For example, you might want the assistant to send a message when the user opens the chat window, or you might want to prompt the user if they haven't sent a message for a while. This page is a guide to enabling your assistant to reach out to the user proactively. --- -Sometimes you want your assistant to reach out to the user without the user's prompting. -For example, you might want the assistant to send a message when the user opens the chat window, -or you might want to prompt the user if they haven't sent a message for a while. -This page is a guide to enabling your assistant to reach out to the user proactively. - ## Reaching out first -To have your assistant reach out to the user at the beginning of a conversation, -configure your [messaging or voice channel](messaging-and-voice-channels.mdx) to send a payload to the bot that -will trigger the appropriate response. For example, in Sara, the Rasa bot, when a -user opens the chat window, the chat widget sends the payload `/greet`, so that -Sara greets the user with a welcome message. How you send the initial payload -will depend on the channel(s) you are using. +In most use cases, when the user opens the chat window with your assistant, you will want the +assistant to send the first message. Doing this can give the user an idea of what the bot +can or can't do and set them up to have a more successful conversation. +Some [messaging or voice channels](./messaging-and-voice-channels.mdx) have existing configuration +options to send a payload to the assistant when the user first starts the conversation, +but you can also add this option to your [own custom channel](./connectors/your-own-website.mdx). -On the bot's side, -you might want to reuse an existing intent and response, or have a specific -intent and response for the start of conversations. If you want a specific welcome -message that the user won't also see by e.g. greeting the bot, you need -to add the intent and response(s) to your domain, and add a rule -for what the bot should do with the initial payload. +Once you've configured your channel to send a payload, you will need to specify how the +assistant should react and greet the user. You can either re-use an existing intent's behaviour +for this, or specify a new intent and rule for this. Below is a guide on how to specify a +welcome rule. -### Data +### 1. Updating the configuration -Using the following example training data, your assistant -will send the `utter_welcome` response when the `chat_opened` intent is predicted: +Since you are using a rule for this behaviour, you need to add the [RulePolicy](./policies.mdx#rule-policy) +to your `config.yml`: -```rasa-yaml -intents: -- chat_opened + ```yaml-rasa + policies: + # other policies + - name: RulePolicy + ``` +### 2. Adding a rule -responses: - utter_welcome: - - text: Hi there! What can I help you with today? - -rules: - - rule: welcome user - steps: - - intent: chat_opened - - action: utter_welcome -``` +To have the assistant respond to the intent `greet` with a welcome message +only at the beginning of a conversation, add the following rule to your +`rules.yml` file: -Since there's no training data for the intent `chat_opened`, the intent can only -be triggered explicitly by sending "/chat_opened", which is what your channel -should send to the bot. + ```yaml-rasa + rules: + - rule: welcome user + conversation_start: True # this rule only applies at the beginning of a conversation + steps: + - intent: greet + - action: utter_welcome + ``` -### Try it Out +### 3. Adding a response template -If you don't yet have a channel set up for your assistant, you can use [rasa-webchat](https://github.com/botfront/rasa-webchat), -a [websocket channel](./connectors/your-own-website.mdx) -and configure the [`initPayload`](https://github.com/botfront/rasa-webchat#parameters) to send the message `/chat_opened`. -After retraining your model, start the rasa server: +Finally, add a template for the `utter_welcome` response to your `domain.yml`: -```shell -rasa run --enable-api --debug +```rasa-yaml +responses: + utter_welcome: + - text: Hi there! What can I help you with today? ``` -In the `rasa-webchat` widget, you should now be greeted with the message, "Hi there! What can I help you with today?" - - ## External Events Sometimes you want an external device to change the course of an ongoing conversation.