Handing off to human on Slack

Hi @mia.le0711! I actually implemented something like that last week :slight_smile:

I created a custom action that:

  • dispatch a message to the user that it is struggling and will handover to a human
  • sends a message in a Slack channel with some information about the issue
  • pause the bot by returning the ConversationPaused() event

On Slack, you need to create an App and get your credentials. I gave it permission to post in any channel but that’s up to you.

Using the Slack v1 API (it will be different if you use v2), I did something like:

response = client_slack.api_call(
    "chat.postMessage", 
    channel="#support", 
    text=f"@botsupport user {tracker.sender_id}" is struggling! Please take over", 
    link_names=1 
)

Note that the link_ǹames is here because I am tagging a group of users in the text with @botsupport (this does not work with direct mention of a user, only groups)

Finally, as mentioned in the doc you linked, I added a trigger on a specific intent to trigger this handover action. I also do something like that if the bot struggles several time in a row.

Hope this helps!! Nicolas