I have a bot running on Slack and some custom actions to cluster incoming data. I want to now bold the cluster names so that they are emphasized and easier to read, e.g.:
“Your Effects so far are clustered as follows:”
Landscape:
- water resources will dry up
- limitation of inhabitable land
- draught
Political:
- social injustice
…
The problem is that I cannot use markdown fuctions, since the data is processed in real-time, clusters are identified and then shown as output by the bot, so it cannot be a pre-defined response. Using color package or specifying color of the text only works in the console, but it not in Rasa X or Slack.
Here is the custom action:
class ActionMidSumEffects(Action):
def name(self) -> Text:
return "action_mid_sum_effects"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
print("Creating Mid Summary for Effects:")
# Get Desired Output (only unique intents - merge same intents)
midsum_effects_output = []
for i in range(len(list_effects_intent)):
skip: bool = False
for i2 in midsum_effects_output:
if i2['Intent'][0] == list_effects_intent[i]:
print("Found Double Intents -> Setting skip=True -> Merging")
skip = True
i2['Texts'].append(list_effects_text[i])
if not skip:
cur_intent = {'Intent': [list_effects_intent[i]], 'Texts': [list_effects_text[i]]}
midsum_effects_output.append(cur_intent)
print("Finished Creating Effects Output:")
print(midsum_effects_output)
out = "Your Effects so far are clustered as follows:\n"
for i3 in midsum_effects_output: # Add Intents
out = out + str(i3['Intent'][0]) + ":\n"
for i4 in i3['Texts']: # Add Texts
out = out + " - " + (str(i4)) + "\n"
print("Effects Output to Dispatcher:")
print(out)
dispatcher.utter_message(text=out)
return []