original_docstring: 
          Counts the number of successful conversations of the bot
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param fallback_action: fallback action configured for bot
          :param nlu_fallback_action: nlu fallback configured for bot
          :return: number of successful conversations
          
docstring: Counts the number of successful conversations of the bot
docstring_tokens: Counts the number of successful conversations of the bot
code: def successful_conversations(collection: Text,
                                   month: int = 1,
                                   fallback_action: str = 'action_default_fallback',
                                   nlu_fallback_action: str = 'nlu_fallback'):
  
          """
          Counts the number of successful conversations of the bot
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param fallback_action: fallback action configured for bot
          :param nlu_fallback_action: nlu fallback configured for bot
          :return: number of successful conversations
          """
          client, message = HistoryProcessor.get_mongo_connection()
          message = ' '.join([message, f', collection: {collection}'])
          with client as client:
              db = client.get_database()
              conversations = db.get_collection(collection)
              total = []
              fallback_count = []
              try:
                  total = list(
                      conversations.aggregate([{"$unwind": {"path": "$events", "includeArrayIndex": "arrayIndex"}},
                                               {"$match": {"events.timestamp": {"$gte": Utility.get_timestamp_previous_month(month)}}},
                                               {"$group": {"_id": "$sender_id"}},
                                               {"$group": {"_id": None, "count": {"$sum": 1}}},
                                               {"$project": {"_id": 0, "count": 1}}
                                               ]))
              except Exception as e:
                  logger.error(e)
                  message = '\n'.join([message, str(e)])
  
              try:
                  fallback_count = list(
                      conversations.aggregate([
                          {"$unwind": {"path": "$events", "includeArrayIndex": "arrayIndex"}},
                          {"$match": {"events.timestamp": {"$gte": Utility.get_timestamp_previous_month(month)}}},
                          {"$match": {'$or': [{"events.name": fallback_action}, {"events.name": nlu_fallback_action}]}},
                          {"$group": {"_id": "$sender_id"}},
                          {"$group": {"_id": None, "count": {"$sum": 1}}},
                          {"$project": {"_id": 0, "count": 1}}
                      ]))
  
              except Exception as e:
                  logger.error(e)
                  message = '\n'.join([message, str(e)])
  
              if not total:
                  total_count = 0
              else:
                  total_count = total[0]['count'] if total[0]['count'] else 0
  
              if not fallback_count:
                  fallbacks_count = 0
              else:
                  fallbacks_count = fallback_count[0]['count'] if fallback_count[0]['count'] else 0
  
              return (
                  {"successful_conversations": total_count-fallbacks_count, "total": total_count},
                  message
              )
code_tokens: def successful_conversations ( collection : Text , month : int = 1 , fallback_action : str = 'action_default_fallback' , nlu_fallback_action : str = 'nlu_fallback' ) : client , message = HistoryProcessor . get_mongo_connection ( ) message = ' ' . join ( [ message , f', collection: {collection}' ] ) with client as client : db = client . get_database ( ) conversations = db . get_collection ( collection ) total = [ ] fallback_count = [ ] try : total = list ( conversations . aggregate ( [ { "$unwind" : { "path" : "$events" , "includeArrayIndex" : "arrayIndex" } } , { "$match" : { "events.timestamp" : { "$gte" : Utility . get_timestamp_previous_month ( month ) } } } , { "$group" : { "_id" : "$sender_id" } } , { "$group" : { "_id" : None , "count" : { "$sum" : 1 } } } , { "$project" : { "_id" : 0 , "count" : 1 } } ] ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) try : fallback_count = list ( conversations . aggregate ( [ { "$unwind" : { "path" : "$events" , "includeArrayIndex" : "arrayIndex" } } , { "$match" : { "events.timestamp" : { "$gte" : Utility . get_timestamp_previous_month ( month ) } } } , { "$match" : { '$or' : [ { "events.name" : fallback_action } , { "events.name" : nlu_fallback_action } ] } } , { "$group" : { "_id" : "$sender_id" } } , { "$group" : { "_id" : None , "count" : { "$sum" : 1 } } } , { "$project" : { "_id" : 0 , "count" : 1 } } ] ) ) except Exception as e : logger . error ( e ) message = '\n' . join ( [ message , str ( e ) ] ) if not total : total_count = 0 else : total_count = total [ 0 ] [ 'count' ] if total [ 0 ] [ 'count' ] else 0 if not fallback_count : fallbacks_count = 0 else : fallbacks_count = fallback_count [ 0 ] [ 'count' ] if fallback_count [ 0 ] [ 'count' ] else 0 return ( { "successful_conversations" : total_count - fallbacks_count , "total" : total_count } , message )
short_docstring: Counts the number of successful conversations of the bot
short_docstring_tokens: Counts the number of successful conversations of the bot
comment: """
          Counts the number of successful conversations of the bot
  
          :param collection: collection to connect to
          :param month: default is current month and max is last 6 months
          :param fallback_action: fallback action configured for bot
          :param nlu_fallback_action: nlu fallback configured for bot
          :return: number of successful conversations
          """