{"id":1881,"date":"2022-03-12T19:23:18","date_gmt":"2022-03-12T19:23:18","guid":{"rendered":"https:\/\/blog.ultramsg.com\/%d8%ac%d8%b9%d9%84-%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-chatbot-using-python-ultramsg\/"},"modified":"2022-03-12T19:55:53","modified_gmt":"2022-03-12T19:55:53","slug":"%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-%d8%b4%d8%a7%d8%aa-%d8%a8%d9%88%d8%aa-%d8%a8%d8%a5%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-%d8%a8%d8%a7%d9%8a%d8%ab%d9%88%d9%86","status":"publish","type":"post","link":"https:\/\/blog.ultramsg.com\/ar\/%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-%d8%b4%d8%a7%d8%aa-%d8%a8%d9%88%d8%aa-%d8%a8%d8%a5%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-%d8%a8%d8%a7%d9%8a%d8%ab%d9%88%d9%86\/","title":{"rendered":"\u0628\u0646\u0627\u0621 \u0648\u0627\u062a\u0633 \u0627\u0628 \u0634\u0627\u062a \u0628\u0648\u062a \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Python"},"content":{"rendered":"\n<p><\/p>\n\n<p>\u0645\u0646 \u0627\u0644\u0633\u0647\u0644 \u062c\u062f\u064b\u0627 \u0625\u0646\u0634\u0627\u0621 chatbot \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0648\u0627\u062c\u0647\u0629 Ultramsg API \u060c \u064a\u0645\u0643\u0646\u0643 \u0625\u0646\u0634\u0627\u0621 \u0631\u0648\u0628\u0648\u062a \u0645\u062d\u0627\u062f\u062b\u0629 \u0644\u062e\u062f\u0645\u0629 \u0627\u0644\u0639\u0645\u0644\u0627\u0621 \u0648\u0628\u0631\u0645\u062c\u0629 \u0631\u0648\u0628\u0648\u062a \u0630\u0643\u064a \u0644\u0644\u0625\u0633\u062a\u0639\u0644\u0627\u0645 \u0645\u0646 \u0642\u0627\u0639\u062f\u0629 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0648\u0627\u0633\u062a\u0642\u0628\u0627\u0644 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0645\u0646 \u0627\u0644\u0639\u0645\u0644\u0627\u0621 \u0648\u0645\u0639\u0627\u0644\u062c\u062a\u0647\u0627 \u0645\u0646 \u062e\u0644\u0627\u0644 \u062e\u0637\u0648\u0627\u062a \u0628\u0633\u064a\u0637\u0629 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0644\u063a\u0629 Python.<\/p>\n\n<h2 class=\"wp-block-heading\">\u0645\u0647\u0627\u0645 \u0627\u0644\u0640 WhatsApp bot<\/h2>\n\n<ul class=\"wp-block-list\"><li>\u0625\u062e\u0631\u0627\u062c \u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0623\u0648\u0627\u0645\u0631.<\/li><li>\u0646\u0627\u062a\u062c \u0648\u0642\u062a \u0627\u0644\u062e\u0627\u062f\u0645 \u0644\u0644\u0631\u0648\u0628\u0648\u062a \u0627\u0644\u0630\u064a \u064a\u0639\u0645\u0644 \u0639\u0644\u0649.<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0635\u0648\u0631\u0629 \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629.<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u0645\u0644\u0641 \u0635\u0648\u062a\u064a.<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u062a\u0633\u062c\u064a\u0644 \u0635\u0648\u062a\u064a ppt.<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u0645\u0644\u0641 \u0641\u064a\u062f\u064a\u0648.<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u062c\u0647\u0629 \u0627\u062a\u0635\u0627\u0644.<a href=\"https:\/\/github.com\/ultramsg\/python-whatsApp-bot#getting-started\" target=\"_blank\" rel=\"noopener\"><\/a><\/li><\/ul>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 1: \u062a\u062b\u0628\u064a\u062a flask<br\/><\/h2>\n\n<p>\u0646\u062d\u062a\u0627\u062c \u0625\u0644\u0649 \u0646\u0634\u0631 \u0627\u0644\u062e\u0627\u062f\u0645 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0625\u0637\u0627\u0631 \u0639\u0645\u0644 FLASK.<br\/>\u064a\u0633\u0645\u062d FLASK \u0628\u0627\u0644\u0627\u0633\u062a\u062c\u0627\u0628\u0629 \u0628\u0634\u0643\u0644 \u0645\u0644\u0627\u0626\u0645 \u0644\u0644\u0637\u0644\u0628\u0627\u062a \u0627\u0644\u0648\u0627\u0631\u062f\u0629 \u0648\u0645\u0639\u0627\u0644\u062c\u062a\u0647\u0627.<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">pip install flask<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 \u0627\u0644\u062b\u0627\u0646\u064a\u0629: \u062a\u062b\u0628\u064a\u062a ngrok<br\/><\/h2>\n\n<p>\u0644\u0623\u063a\u0631\u0627\u0636 \u0627\u0644\u062a\u062c\u0631\u0628\u0629 \u0628\u0627\u0644\u0633\u064a\u0631\u0641\u0631 \u0627\u0644\u0645\u062d\u0644\u064a \u0633\u0646\u062d\u062a\u0627\u062c \u0644\u062e\u062f\u0645\u0629 tunneling \u0648 \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u062f\u0631\u0633 \u0633\u0646\u0633\u062a\u062e\u062f\u0645 ngrok \u064a\u0645\u0643\u0646\u0643 \u062a\u062d\u0645\u064a\u0644 <a href=\"https:\/\/ngrok.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">ngrok<\/a> \u0645\u0646 <a href=\"https:\/\/ngrok.com\/download\" target=\"_blank\" rel=\"noreferrer noopener\">\u0647\u0646\u0627<\/a> .<\/p>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 3: \u0625\u0646\u0634\u0627\u0621 \u062a\u0637\u0628\u064a\u0642 flask \u062c\u062f\u064a\u062f<\/h2>\n\n<p>\u0633\u0646\u0646\u0634\u0626 \u0627\u0644\u0645\u0644\u0641: <strong>app.py \u0648\u0646\u0643\u062a\u0628<\/strong> \u0627\u0644\u0643\u0648\u062f \u0627\u0644\u062a\u0627\u0644\u064a \u0628\u062f\u0627\u062e\u0644\u0647<\/p>\n\n<pre class=\"wp-block-preformatted\"><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">from flask import Flask, request, jsonify\nfrom ultrabot import ultraChatBot\nimport json\n\napp = Flask(__name__)\n\n@app.route('\/', methods=['POST'])\ndef home():\n    if request.method == 'POST':\n        bot = ultraChatBot(request.json)\n        return bot.Processing\u0640incoming\u0640messages()\n\nif(__name__) == '__main__':\n    app.run()<\/code><\/pre>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 4: \u0645\u0639\u0627\u0644\u062c\u0629 \u0627\u0644\u0631\u0633\u0627\u0626\u0644 \u0627\u0644\u0648\u0627\u0631\u062f\u0629<\/h2>\n\n<p>\u0633\u0646\u0646\u0634\u0626 \u0627\u0644\u0645\u0644\u0641: <strong>ultrabot.py \u0648\u0646\u0643\u062a\u0628<\/strong> \u0627\u0644\u0643\u0648\u062f \u0627\u0644\u062a\u0627\u0644\u064a \u0628\u062f\u0627\u062e\u0644\u0647<\/p>\n\n<pre class=\"wp-block-preformatted\"><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">import json\nimport requests\nimport datetime\n\nclass ultraChatBot():    \n    def __init__(self, json):\n        self.json = json\n        self.dict_messages = json['data']\n        self.ultraAPIUrl = 'https:\/\/api.ultramsg.com\/{{instance_id}}\/'\n        self.token = '{{token}}'\n\n   \n    def send_requests(self, type, data):\n        url = f\"{self.ultraAPIUrl}{type}?token={self.token}\"\n        headers = {'Content-type': 'application\/json'}\n        answer = requests.post(url, data=json.dumps(data), headers=headers)\n        return answer.json()\n\n    def send_message(self, chatID, text):\n        data = {\"to\" : chatID,\n                \"body\" : text}  \n        answer = self.send_requests('messages\/chat', data)\n        return answer\n\n    def send_image(self, chatID):\n        data = {\"to\" : chatID,\n                \"image\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/images\/test.jpeg\"}  \n        answer = self.send_requests('messages\/image', data)\n        return answer\n\n    def send_video(self, chatID):\n        data = {\"to\" : chatID,\n                \"video\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/video\/test.mp4\"}  \n        answer = self.send_requests('messages\/video', data)\n        return answer\n\n    def send_audio(self, chatID):\n        data = {\"to\" : chatID,\n                \"audio\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/audio\/2.mp3\"}  \n        answer = self.send_requests('messages\/audio', data)\n        return answer\n\n\n    def send_voice(self, chatID):\n        data = {\"to\" : chatID,\n                \"audio\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/voice\/oog_example.ogg\"}  \n        answer = self.send_requests('messages\/voice', data)\n        return answer\n\n    def send_contact(self, chatID):\n        data = {\"to\" : chatID,\n                \"contact\" : \"14000000001@c.us\"}  \n        answer = self.send_requests('messages\/contact', data)\n        return answer\n\n\n    def time(self, chatID):\n        t = datetime.datetime.now()\n        time = t.strftime('%Y-%m-%d %H:%M:%S')\n        return self.send_message(chatID, time)\n\n\n    def welcome(self,chatID, noWelcome = False):\n        welcome_string = ''\n        if (noWelcome == False):\n            welcome_string = \"Hi , welcome to WhatsApp chatbot using Python\\n\"\n        else:\n            welcome_string = \"\"\"wrong command\nPlease type one of these commands:\n*hi* : Saluting\n*time* : show server time\n*image* : I will send you a picture\n*video* : I will send you a Video\n*audio* : I will send you a audio file\n*voice* : I will send you a ppt audio recording\n*contact* : I will send you a contact\n\"\"\"\n        return self.send_message(chatID, welcome_string)\n\n\n    def Processing\u0640incoming\u0640messages(self):\n        if self.dict_messages != []:\n            message =self.dict_messages\n            text = message['body'].split()\n            if not message['fromMe']:\n                chatID  = message['from'] \n                if text[0].lower() == 'hi':\n                    return self.welcome(chatID)\n                elif text[0].lower() == 'time':\n                    return self.time(chatID)\n                elif text[0].lower() == 'image':\n                    return self.send_image(chatID)\n                elif text[0].lower() == 'video':\n                    return self.send_video(chatID)\n                elif text[0].lower() == 'audio':\n                    return self.send_audio(chatID)\n                elif text[0].lower() == 'voice':\n                    return self.send_voice(chatID)\n                elif text[0].lower() == 'contact':\n                    return self.send_contact(chatID)\n                else:\n                    return self.welcome(chatID, True)\n            else: return 'NoCommand'<\/code><\/pre>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 5: \u0627\u0628\u062f\u0623 \u0645\u0634\u0631\u0648\u0639 WhatsApp Chatbot <\/h2>\n\n<h3 class=\"wp-block-heading\">\u062a\u0634\u063a\u064a\u0644 \u062e\u0627\u062f\u0645 FLASK<\/h3>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">flask run<\/code><\/code><\/pre>\n\n<h3 class=\"wp-block-heading\">\u062a\u0634\u063a\u064a\u0644 ngrok<\/h3>\n\n<p>\u062a\u0634\u063a\u064a\u0644 ngrok \u0644\u0646\u0638\u0627\u0645 \u0627\u0644\u062a\u0634\u063a\u064a\u0644 Windows:<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">ngrok http 5000<\/code><\/code><\/pre>\n\n<p>\u062a\u0634\u063a\u064a\u0644 ngrok \u0644\u0646\u0638\u0627\u0645 \u0627\u0644\u062a\u0634\u063a\u064a\u0644 Mac:<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">.\/ngrok http 5000<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u062e\u0637\u0648\u0629 6: \u062a\u0639\u064a\u064a\u0646 URL Webhook \u0641\u064a \u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u062c\u0647\u0627\u0632<\/h2>\n\n<p>\u0628\u0639\u062f \u062a\u0634\u063a\u064a\u0644 ngrok \u060c \u064a\u062c\u0628 \u0623\u0646 \u062a\u0631\u0649 \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644:<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"powershell\" class=\"EnlighterJSRAW\">https:\/\/7647-115-83-121-164.ngrok.io<\/code><\/code><\/pre>\n\n<p>\u0627\u0644\u0635\u0642 \u0639\u0646\u0648\u0627\u0646 URL \u0627\u0644\u062e\u0627\u0635 \u0628\u0643 \u0641\u064a \u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u062c\u0647\u0627\u0632 \u060c \u0643\u0645\u0627 \u0641\u064a \u0627\u0644\u0635\u0648\u0631\u0629 \u0627\u0644\u062a\u0627\u0644\u064a\u0629:<\/p>\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/blog.ultramsg.com\/wp-content\/uploads\/2022\/03\/image-1024x612.png\" alt=\"&#x627;&#x633;&#x62A;&#x642;&#x628;&#x627;&#x644; &#x631;&#x633;&#x627;&#x626;&#x644; WhatsApp &#x628;&#x627;&#x633;&#x62A;&#x62E;&#x62F;&#x627;&#x645; Python &#x648; webhook-ultramsg\" title=\"\"><\/figure><\/div>\n\n<h2 class=\"wp-block-heading\">\u0648\u0638\u0627\u0626\u0641 Chatbot \u0627\u0644\u0645\u0633\u062a\u062e\u062f\u0645\u0629 \u0641\u064a \u0627\u0644\u0643\u0648\u062f<\/h2>\n\n<h3 class=\"wp-block-heading\">send_message<\/h3>\n\n<p>\u062a\u0633\u062a\u062e\u062f\u0645 \u0644\u0625\u0631\u0633\u0627\u0644 \u0631\u0633\u0627\u0626\u0644 \u0646\u0635\u064a\u0629 WhatsApp<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_message(self, chatID, text):\n    data = {\"to\" : chatID,\n        \"body\" : text}  \n    answer = self.send_requests('messages\/chat', data)\n    return answer<\/code><\/code><\/pre>\n\n<ul class=\"wp-block-list\"><li>ChatID &#8211; \u0645\u0639\u0631\u0641 \u0627\u0644\u062f\u0631\u062f\u0634\u0629 \u062d\u064a\u062b \u064a\u062c\u0628 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0631\u0633\u0627\u0644\u0629 \u0644\u0647 \u060c \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644 <a href=\"mailto:14155552671@c.us\">14155552671@c.us<\/a> .<\/li><li>\u0646\u0635 &#8211; \u0646\u0635 \u0627\u0644\u0631\u0633\u0627\u0644\u0629.<\/li><\/ul>\n\n<h3 class=\"wp-block-heading\">time<\/h3>\n\n<p>\u064a\u0631\u0633\u0644 \u0648\u0642\u062a \u0627\u0644\u062e\u0627\u062f\u0645 \u0627\u0644\u062d\u0627\u0644\u064a.<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def time(self, chatID):\n    t = datetime.datetime.now()\n    time = t.strftime('%Y-%m-%d %H:%M:%S')\n    return self.send_message(chatID, time)<\/code><\/code><\/pre>\n\n<ul class=\"wp-block-list\"><li>ChatID &#8211; \u0645\u0639\u0631\u0641 \u0627\u0644\u062f\u0631\u062f\u0634\u0629 \u062d\u064a\u062b \u064a\u062c\u0628 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0631\u0633\u0627\u0644\u0629 \u0644\u0647 \u060c \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644 <a href=\"mailto:14155552671@c.us\">14155552671@c.us<\/a> .<\/li><\/ul>\n\n<h3 class=\"wp-block-heading\">send_image<\/h3>\n\n<p>\u0623\u0631\u0633\u0644 \u0635\u0648\u0631\u0629 \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_image(self, chatID):\n    data = {\"to\" : chatID,\n        \"image\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/images\/test.jpeg\"}  \n    answer = self.send_requests('messages\/image', data)\n    return answer<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/ultramsg\/python-whatsApp-bot#send_video\" target=\"_blank\" rel=\"noopener\"><\/a><a href=\"https:\/\/github.com\/ultramsg\/python-whatsApp-bot#send_image\" target=\"_blank\" rel=\"noopener\"><\/a><\/h2>\n\n<h3 class=\"wp-block-heading\">send_video<\/h3>\n\n<p>\u0623\u0631\u0633\u0644 \u0645\u0642\u0637\u0639 \u0641\u064a\u062f\u064a\u0648 \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_video(self, chatID):\n    data = {\"to\" : chatID,\n        \"video\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/video\/test.mp4\"}  \n    answer = self.send_requests('messages\/video', data)\n    return answer<\/code><\/code><\/pre>\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/ultramsg\/python-whatsApp-bot#time\" target=\"_blank\" rel=\"noopener\"><\/a><\/h2>\n\n<h3 class=\"wp-block-heading\">send_audio<\/h3>\n\n<p>\u0623\u0631\u0633\u0644 \u0645\u0644\u0641\u064b\u0627 \u0635\u0648\u062a\u064a\u064b\u0627 \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_audio(self, chatID):\n    data = {\"to\" : chatID,\n        \"audio\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/audio\/2.mp3\"}  \n    answer = self.send_requests('messages\/audio', data)\n    return answer<\/code><\/code><\/pre>\n\n<h3 class=\"wp-block-heading\">send_voice<br\/><\/h3>\n\n<p>\u0623\u0631\u0633\u0644 \u062a\u0633\u062c\u064a\u0644 \u0635\u0648\u062a\u064a ppt \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_voice(self, chatID):\n    data = {\"to\" : chatID,\n        \"audio\" : \"https:\/\/file-example.s3-accelerate.amazonaws.com\/voice\/oog_example.ogg\"}  \n    answer = self.send_requests('messages\/voice', data)\n    return answer<\/code><\/code><\/pre>\n\n<h3 class=\"wp-block-heading\">send_contact<\/h3>\n\n<p>\u0625\u0631\u0633\u0627\u0644 \u062c\u0647\u0629 \u0627\u062a\u0635\u0627\u0644 \u0648\u0627\u062d\u062f\u0629 \u0623\u0648 \u0642\u0627\u0626\u0645\u0629 \u062c\u0647\u0627\u062a \u0627\u062a\u0635\u0627\u0644 \u0625\u0644\u0649 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u0623\u0648 \u0627\u0644\u0645\u062c\u0645\u0648\u0639\u0629<\/p>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def send_contact(self, chatID):\n    data = {\"to\" : chatID,\n        \"contact\" : \"14000000001@c.us\"}  \n    answer = self.send_requests('messages\/contact', data)\n    return answer<\/code><\/code><\/pre>\n\n<h3 class=\"wp-block-heading\">Processing\u0640incoming\u0640messages<\/h3>\n\n<pre class=\"wp-block-code\"><code><code data-enlighter-language=\"python\" class=\"EnlighterJSRAW\">def Processing\u0640incoming\u0640messages(self):\n    if self.dict_messages != &#91;]:\n        message =self.dict_messages\n        text = message&#91;'body'].split()\n        if not message&#91;'fromMe']:\n        chatID  = message&#91;'from'] \n        if text&#91;0].lower() == 'hi':\n            return self.welcome(chatID)\n        elif text&#91;0].lower() == 'time':\n            return self.time(chatID)\n        elif text&#91;0].lower() == 'image':\n            return self.send_image(chatID)\n        elif text&#91;0].lower() == 'video':\n            return self.send_video(chatID)\n        elif text&#91;0].lower() == 'audio':\n            return self.send_audio(chatID)\n        elif text&#91;0].lower() == 'voice':\n            return self.send_voice(chatID)\n        elif text&#91;0].lower() == 'contact':\n            return self.send_contact(chatID)\n        else:\n            return self.welcome(chatID, True)\n        else: return 'NoCommand'<\/code><\/code><\/pre>\n\n<p>\u064a\u0645\u0643\u0646\u0643 \u0645\u0634\u0627\u0647\u062f\u0629 \u0627\u0644\u062e\u0637\u0648\u0627\u062a \u0627\u0644\u0633\u0627\u0628\u0642\u0629 \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0641\u064a\u062f\u064a\u0648:<\/p>\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Build a WhatsApp Chatbot With Python using Ultramsg WhatsApp API\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/W3dQp375wWY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n<h2 class=\"wp-block-heading\">\u0631\u0648\u0627\u0628\u0637 \u0645\u0641\u064a\u062f\u0629<\/h2>\n\n<ul class=\"wp-block-list\"><li>\u0643\u0644 \u0627\u0644\u0643\u0648\u062f \u0645\u062a\u0627\u062d \u0639\u0644\u0649 <a href=\"https:\/\/github.com\/ultramsg\/python-whatsApp-bot\" target=\"_blank\" rel=\"noopener\">GitHub<\/a> .<\/li><li>\u0625\u0631\u0633\u0627\u0644 \u0631\u0633\u0627\u0626\u0644 <a href=\"https:\/\/blog.ultramsg.com\/ar\/%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-api-%d9%85%d8%b9-%d9%84%d8%ba%d8%a9-%d8%a8%d8%a7%d9%8a%d8%ab%d9%88%d9%86\/\" data-type=\"URL\" data-id=\"https:\/\/blog.ultramsg.com\/programmable-whatsapp-api-messaging-using-python\/\">WhatsApp API<\/a> \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Python.<\/li><li><a href=\"https:\/\/www.youtube.com\/watch?v=kipBHDOsFKI\" data-type=\"URL\" data-id=\"https:\/\/www.youtube.com\/watch?v=kipBHDOsFKI\" rel=\"nofollow noopener\" target=\"_blank\">\u0643\u064a\u0641\u064a\u0629 \u0636\u0628\u0637 WebHooks \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0645\u0646\u0635\u0629 Ultramsg<\/a><\/li><li>\u0643\u064a\u0641\u064a\u0629 <a href=\"https:\/\/blog.ultramsg.com\/ar\/%d9%83%d9%8a%d9%81-%d8%aa%d8%b3%d8%aa%d9%82%d8%a8%d9%84-%d8%b1%d8%b3%d8%a7%d8%a6%d9%84-%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-%d8%a8%d9%8a%d8%ab%d9%88%d9%86-%d9%88%d9%8a%d8%a8-%d9%87%d9%88%d9%83\/\" data-type=\"URL\" data-id=\"https:\/\/blog.ultramsg.com\/how-to-receive-whatsapp-messages-python-webhook\/\">\u062a\u0644\u0642\u064a \u0631\u0633\u0627\u0626\u0644 WhatsApp<\/a> \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Python \u0648 webhook.<\/li><\/ul>\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0645\u0646 \u0627\u0644\u0633\u0647\u0644 \u062c\u062f\u064b\u0627 \u0625\u0646\u0634\u0627\u0621 chatbot \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0648\u0627\u062c\u0647\u0629 Ultramsg API \u060c \u064a\u0645\u0643\u0646\u0643 \u0625\u0646\u0634\u0627\u0621 \u0631\u0648\u0628\u0648\u062a \u0645\u062d\u0627\u062f\u062b\u0629 \u0644\u062e\u062f\u0645\u0629 &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"\u0628\u0646\u0627\u0621 \u0648\u0627\u062a\u0633 \u0627\u0628 \u0634\u0627\u062a \u0628\u0648\u062a \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Python\" class=\"read-more button\" href=\"https:\/\/blog.ultramsg.com\/ar\/%d9%88%d8%a7%d8%aa%d8%b3-%d8%a7%d8%a8-%d8%b4%d8%a7%d8%aa-%d8%a8%d9%88%d8%aa-%d8%a8%d8%a5%d8%b3%d8%aa%d8%ae%d8%af%d8%a7%d9%85-%d8%a8%d8%a7%d9%8a%d8%ab%d9%88%d9%86\/#more-1881\" aria-label=\"Read more about \u0628\u0646\u0627\u0621 \u0648\u0627\u062a\u0633 \u0627\u0628 \u0634\u0627\u062a \u0628\u0648\u062a \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 Python\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":1847,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[39,40,176,38],"class_list":["post-1881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category---api","tag-python-ar","tag-40","tag-176","tag---api","infinite-scroll-item","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-25","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/posts\/1881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/comments?post=1881"}],"version-history":[{"count":27,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/posts\/1881\/revisions"}],"predecessor-version":[{"id":1942,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/posts\/1881\/revisions\/1942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/media\/1847"}],"wp:attachment":[{"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/media?parent=1881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/categories?post=1881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ultramsg.com\/ar\/wp-json\/wp\/v2\/tags?post=1881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}