Kaynağa Gözat

Upload files to 'chatbot'

SadhulaSaiKumar 2 yıl önce
ebeveyn
işleme
05f3ac92da
5 değiştirilmiş dosya ile 393 ekleme ve 0 silme
  1. 121
    0
      chatbot/app.py
  2. 38
    0
      chatbot/config.yml
  3. 38
    0
      chatbot/credentials.yml
  4. 150
    0
      chatbot/domain.yml
  5. 46
    0
      chatbot/endpoints.yml

+ 121
- 0
chatbot/app.py Dosyayı Görüntüle

@@ -0,0 +1,121 @@
1
+import requests
2
+from flask import Flask, request, jsonify,render_template
3
+from flask_cors import CORS
4
+
5
+app = Flask(__name__)
6
+
7
+
8
+
9
+CORS(app)
10
+
11
+# import nltk
12
+# nltk.download('popular')
13
+# from nltk.stem import WordNetLemmatizer
14
+# lemmatizer = WordNetLemmatizer()
15
+# import pickle
16
+# import numpy as np
17
+
18
+# from keras.models import load_model
19
+# model = load_model('model.h5')
20
+# import json
21
+# import random
22
+# intents = json.loads(open('data.json').read())
23
+# words = pickle.load(open('texts.pkl','rb'))
24
+# classes = pickle.load(open('labels.pkl','rb'))
25
+
26
+# def clean_up_sentence(sentence):
27
+#     # tokenize the pattern - split words into array
28
+#     sentence_words = nltk.word_tokenize(sentence)
29
+#     # stem each word - create short form for word
30
+#     sentence_words = [lemmatizer.lemmatize(word.lower()) for word in sentence_words]
31
+#     return sentence_words
32
+
33
+# # return bag of words array: 0 or 1 for each word in the bag that exists in the sentence
34
+
35
+# def bow(sentence, words, show_details=True):
36
+#     # tokenize the pattern
37
+#     sentence_words = clean_up_sentence(sentence)
38
+#     # bag of words - matrix of N words, vocabulary matrix
39
+#     bag = [0]*len(words)  
40
+#     for s in sentence_words:
41
+#         for i,w in enumerate(words):
42
+#             if w == s: 
43
+#                 # assign 1 if current word is in the vocabulary position
44
+#                 bag[i] = 1
45
+#                 if show_details:
46
+#                     print ("found in bag: %s" % w)
47
+#     return(np.array(bag))
48
+
49
+# def predict_class(sentence, model):
50
+#     # filter out predictions below a threshold
51
+#     p = bow(sentence, words,show_details=False)
52
+#     res = model.predict(np.array([p]))[0]
53
+#     ERROR_THRESHOLD = 0.25
54
+#     results = [[i,r] for i,r in enumerate(res) if r>ERROR_THRESHOLD]
55
+#     # sort by strength of probability
56
+#     results.sort(key=lambda x: x[1], reverse=True)
57
+#     return_list = []
58
+#     for r in results:
59
+#         return_list.append({"intent": classes[r[0]], "probability": str(r[1])})
60
+#     return return_list
61
+
62
+# def getResponse(ints, intents_json):
63
+#     tag = ints[0]['intent']
64
+#     list_of_intents = intents_json['intents']
65
+#     for i in list_of_intents:
66
+#         if(i['tag']== tag):
67
+#             result = random.choice(i['responses'])
68
+#             break
69
+#     return result
70
+
71
+# def chatbot_response(msg):
72
+#     ints = predict_class(msg, model)
73
+#     res = getResponse(ints, intents)
74
+#     return res
75
+
76
+
77
+
78
+app.static_folder = 'static'
79
+
80
+
81
+
82
+# Define the Rasa server URL
83
+rasa_server_url = "http://localhost:5005/webhooks/rest/webhook"
84
+
85
+@app.route("/")
86
+def home():
87
+    return render_template("index.html")
88
+
89
+
90
+@app.route('/webhook', methods=['POST','GET'])
91
+def webhook():
92
+    message = request.json['message']
93
+   # message =request.args.get('msg')
94
+
95
+    # Send the message to the Rasa server
96
+    rasa_response = requests.post(rasa_server_url, json={"message": message}).json()
97
+ 
98
+    # for d in rasa_response:
99
+    #     a=d["text"]
100
+
101
+    # Return the Rasa response as a JSON object
102
+    print(rasa_response)
103
+    if len(rasa_response)==0:
104
+        return jsonify([
105
+    {
106
+        "recipient_id": "default",
107
+        "text": "I'm sorry, I didn't understand that. Can you please rephrase?"
108
+    }])
109
+    else:
110
+        return jsonify(rasa_response)
111
+
112
+
113
+
114
+@app.route("/get")
115
+def get_bot_response():
116
+    userText = request.args.get('msg')
117
+    return chatbot_response(userText)
118
+
119
+
120
+if __name__ == '__main__':
121
+    app.run(host='0.0.0.0',port=5020)

+ 38
- 0
chatbot/config.yml Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+recipe: default.v1
2
+assistant_id: 20230411-174114-maximum-louver
3
+language: en
4
+pipeline: null
5
+# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
6
+# # If you'd like to customize it, uncomment and adjust the pipeline.
7
+# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
8
+#   - name: WhitespaceTokenizer
9
+#   - name: RegexFeaturizer
10
+#   - name: LexicalSyntacticFeaturizer
11
+#   - name: CountVectorsFeaturizer
12
+#   - name: CountVectorsFeaturizer
13
+#     analyzer: char_wb
14
+#     min_ngram: 1
15
+#     max_ngram: 4
16
+#   - name: DIETClassifier
17
+#     epochs: 100
18
+#     constrain_similarities: true
19
+#   - name: EntitySynonymMapper
20
+#   - name: ResponseSelector
21
+#     epochs: 100
22
+#     constrain_similarities: true
23
+#   - name: FallbackClassifier
24
+#     threshold: 0.3
25
+#     ambiguity_threshold: 0.1
26
+policies: null
27
+# # No configuration for policies was provided. The following default policies were used to train your model.
28
+# # If you'd like to customize them, uncomment and adjust the policies.
29
+# # See https://rasa.com/docs/rasa/policies for more information.
30
+#   - name: MemoizationPolicy
31
+#   - name: RulePolicy
32
+#   - name: UnexpecTEDIntentPolicy
33
+#     max_history: 5
34
+#     epochs: 100
35
+#   - name: TEDPolicy
36
+#     max_history: 5
37
+#     epochs: 100
38
+#     constrain_similarities: true

+ 38
- 0
chatbot/credentials.yml Dosyayı Görüntüle

@@ -0,0 +1,38 @@
1
+# This file contains the credentials for the voice & chat platforms
2
+# which your bot is using.
3
+# https://rasa.com/docs/rasa/messaging-and-voice-channels
4
+
5
+#rest:
6
+#  # you don't need to provide anything here - this channel doesn't
7
+#  # require any credentials
8
+
9
+
10
+# rest:
11
+#   # You can customize the webhook URL to include the user's ID as a parameter
12
+#   webhook_url: "http://localhost:5005/webhooks/rest/webhook?recipient_id={sender_id}"
13
+
14
+#facebook:
15
+#  verify: "<verify>"
16
+#  secret: "<your secret>"
17
+#  page-access-token: "<your page access token>"
18
+
19
+#slack:
20
+#  slack_token: "<your slack token>"
21
+#  slack_channel: "<the slack channel>"
22
+#  slack_signing_secret: "<your slack signing secret>"
23
+
24
+#socketio:
25
+#  user_message_evt: <event name for user message>
26
+#  bot_message_evt: <event name for bot messages>
27
+#  session_persistence: <true/false>
28
+
29
+#mattermost:
30
+#  url: "https://<mattermost instance>/api/v4"
31
+#  token: "<bot token>"
32
+#  webhook_url: "<callback URL>"
33
+
34
+# This entry is needed if you are using Rasa Enterprise. The entry represents credentials
35
+# for the Rasa Enterprise "channel", i.e. Talk to your bot and Share with guest testers.
36
+
37
+
38
+

+ 150
- 0
chatbot/domain.yml Dosyayı Görüntüle

@@ -0,0 +1,150 @@
1
+intents:
2
+  - greet
3
+  - goodbye
4
+  - affirm
5
+  - deny
6
+  - mood_great
7
+  - mood_unhappy
8
+  - bot_challenge
9
+  - question1
10
+  - question3
11
+  - question4
12
+  - question5
13
+  - question6
14
+  - docs
15
+  - video
16
+  - connect_support
17
+  - noconnect_support
18
+  
19
+  
20
+entities:
21
+  - content_type
22
+
23
+slots:
24
+  content_type:
25
+    type: text
26
+    mappings:
27
+      - type: from_entity
28
+        entity: content_type
29
+
30
+  
31
+responses:
32
+  utter_cheer_up:
33
+    - image: https://i.imgur.com/nGF1K8f.jpg
34
+      text: 'Here is something to cheer you up:'
35
+  utter_did_that_help:
36
+    - text: Did that help you?
37
+  utter_goodbye:
38
+    - text: Bye
39
+  utter_greet:
40
+    - text: Hey! How are you?
41
+  utter_happy:
42
+    - text: Great, carry on!
43
+  utter_iamabot:
44
+    - text: I am a bot, powered by Rasa.
45
+  utter_question1_1:
46
+    - text: We have explained the process of changing the old to the new manager for
47
+        customers in DMS, Follow the below procedures. 1) Open DMS--->Go to the change
48
+        manager module--->Click on the create option--->Fill in the details--->Save--->Confirm.
49
+        2) customer module--then select customer--edit the sale manager's name to
50
+        the required employee and save to reflect in his login
51
+  utter_question1_2:
52
+    - text: To change the manager for customers in DMS, first, open the DMS system,
53
+        then navigate to the "change manager" module, click on the "create" option,
54
+        fill in the necessary details, save the changes, and confirm the update. Next,
55
+        go to the "customer" module, select the relevant customer, edit the sales
56
+        manager's name to the desired employee, and save the changes to reflect the
57
+        update in their login
58
+  utter_question1_3:
59
+    - text: The process of changing the manager for customers in DMS involves several
60
+        steps. First, access the DMS system and open the "change manager" module.
61
+        From there, click on the "create" option, provide the required details, and
62
+        save the changes. Once the update is confirmed, navigate to the "customer"
63
+        module, select the appropriate customer, modify the sales manager's name to
64
+        the preferred employee, and save the changes to ensure that it reflects in
65
+        their login.
66
+
67
+  utter_question3_1:
68
+    - text: Customers module----> enter the customer name----> Open details----> click
69
+        on sales manager---->edit---->save.
70
+  utter_question3_2:
71
+    - text: If you want to change the sales manager for a particular customer in DMS,
72
+        go to the Customers module and enter the name of the customer. Then, open
73
+        the customer's details, find the "Sales Manager" section, click on it, choose
74
+        the "Edit" option to modify the sales manager's name, enter the new name,
75
+        and save the changes.
76
+  utter_question3_3:
77
+    - text: nan
78
+  utter_question4_1:
79
+    - text: Please find the below process to change the Customer Segment tag Customer
80
+        module--->Select Particular Customer----->click on details------>check on
81
+        + to change the LOB tags.
82
+  utter_question4_2:
83
+    - text: If you need to change the Customer Segment tag for a particular customer
84
+        in DMS, start by accessing the Customer module, selecting the relevant customer,
85
+        and clicking on their details. Once you are in the customer's details, locate
86
+        the "+" symbol to modify the LOB tags and update the Customer Segment tag.
87
+  utter_question4_3:
88
+    - text: To modify the Customer Segment tag for a specific customer in DMS, go
89
+        to the Customer module, find the customer whose tag you want to change, and
90
+        open their details. Then, click on the "+" symbol to add or remove LOB tags,
91
+        and make the necessary changes to the Customer Segment tag.
92
+  utter_question5_1:
93
+    - text: We have explained the process of checking the EB-invoice report through
94
+        remote session & follow the below procedure. Open DMS-----> click on reports----->open
95
+        EB- invoice report---->check.
96
+  utter_question5_2:
97
+    - text: To verify the EB-invoice report through a remote session, follow these
98
+        steps first, access the DMS platform, then navigate to the "reports" section
99
+        and click on the "EB-invoice report." Finally, carefully review the report
100
+        to ensure all necessary information is present and accurate.
101
+  utter_question5_3:
102
+    - text: The process of remotely checking the EB-invoice report can be accomplished
103
+        in a few simple steps. Begin by logging into the DMS platform and selecting
104
+        the "reports" option. From there, click on the "EB-invoice report" and review
105
+        the contents to confirm its accuracy.
106
+  utter_question6_1:
107
+    - text: Please find the below process to add branchto employee Employee module------>Search
108
+        the employee name ---->Open employee----->click on official Widget------>click
109
+        on branches +check on------->click on plus symbol----->select the branch from
110
+        the dropdown ------->save.
111
+  utter_question6_2:
112
+    - text: To assign a branch to an employee, follow these steps first, access the
113
+        Employee module and search for the employee's name. Next, open the employee's
114
+        profile and click on the Official Widget. From there, click on the "branches"
115
+        option and check the box to enable it. Then, click on the plus symbol and
116
+        select the appropriate branch from the dropdown menu. Finally, click on "save"
117
+        to confirm the changes.
118
+  utter_question6_3:
119
+    - text: Adding a branch to an employee is a simple process that involves accessing
120
+        the Employee module and searching for the employee in question. Once you've
121
+        found their profile, open it and click on the Official Widget, followed by
122
+        the "branches" option. Check the box to enable branches, then click the plus
123
+        symbol and select the appropriate branch from the dropdown list. Be sure to
124
+        save your changes before exiting the page.
125
+
126
+  utter_blogs:
127
+  - text: "great carry on" 
128
+
129
+  utter_video:
130
+  - text: "do you want me to connect you to support team" 
131
+
132
+
133
+  utter_connect_support:
134
+  - text: "Im conneting you to support team" 
135
+
136
+  utter_noconnect_support:
137
+  - text: "great carry on" 
138
+
139
+actions:
140
+  - action_service
141
+  - action_suport_service
142
+  # - action_save_conersation
143
+  # - action_clear_conversation
144
+ 
145
+
146
+
147
+session_config:
148
+  carry_over_slots_to_new_session: true
149
+  session_expiration_time: 60
150
+version: '3.1'

+ 46
- 0
chatbot/endpoints.yml Dosyayı Görüntüle

@@ -0,0 +1,46 @@
1
+# This file contains the different endpoints your bot can use.
2
+
3
+# Server where the models are pulled from.
4
+# https://rasa.com/docs/rasa/model-storage#fetching-models-from-a-server
5
+
6
+#models:
7
+#  url: http://my-server.com/models/default_core@latest
8
+#  wait_time_between_pulls:  10   # [optional](default: 100)
9
+
10
+# Server which runs your custom actions.
11
+# https://rasa.com/docs/rasa/custom-actions
12
+
13
+action_endpoint:
14
+ url: "http://localhost:5055/webhook?recipient_id={sender_id}"
15
+
16
+# Tracker store which is used to store the conversations.
17
+# By default the conversations are stored in memory.
18
+# https://rasa.com/docs/rasa/tracker-stores
19
+
20
+#tracker_store:
21
+#    type: redis
22
+#    url: <host of the redis instance, e.g. localhost>
23
+#    port: <port of your redis instance, usually 6379>
24
+#    db: <number of your database within redis, e.g. 0>
25
+#    password: <password used for authentication>
26
+#    use_ssl: <whether or not the communication is encrypted, default false>
27
+
28
+#tracker_store:
29
+#    type: mongod
30
+#    url: <url to your mongo instance, e.g. mongodb://localhost:27017>
31
+#    db: <name of the db within your mongo instance, e.g. rasa>
32
+#    username: <username used for authentication>
33
+#    password: <password used for authentication>
34
+
35
+# Event broker which all conversation events should be streamed to.
36
+# https://rasa.com/docs/rasa/event-brokers
37
+
38
+#event_broker:
39
+#  url: localhost
40
+#  username: username
41
+#  password: password
42
+#  queue: queue
43
+
44
+
45
+
46
+

Loading…
İptal
Kaydet