Solution 1
In the domain:
responses:
utter_greet:
- text: "Hello, this is Alfred"
channel: "slack"
- text: "Hello, this is John"
channel: "facebook"
- text: "Hello, this is Chris"
Reference: Channel-Specific Response Variations
Solution 2
In the actions:
class ActionGreet(Action):
def name(self):
return "action_greet"
async def run(self, dispatcher, tracker, domain):
channel = tracker.get_latest_input_channel().lower()
name = "Chris"
if channel == "slack":
name = "Alfred"
elif channel == "facebook":
name = "John"
dispatcher.utter_message(text = f"Hello, this is {name}")
Reference: Tracker.get_latest_input_channel
Note
Make sure the value of the channel
key matches the value returned by the name()
method of your input channel. If you are using a built-in channel, this value will also match the channel name used in your credentials.yml
file.