WhatsApp Customer Engagement Workflow

Automated WhatsApp customer engagement with AI-powered intent analysis and response generation

Back
Workflow Information

ID: whatsapp_customer_engagement_workflow

Namespace: default

Version: 1.0

Created: 2025-07-01

Updated: 2025-07-01

Tasks: 17

Quick Actions
Manage Secrets
Inputs
Name Type Required Default
message_id string Optional wamid.HBgLMTIzNDU2Nzg5MDE...
sender_phone string Optional +1234567890
Outputs
Name Type Source
escalation_details object Human escalation details if applicable
message_processing object WhatsApp message processing results
conversation_record object Complete conversation log and follow-up schedule
customer_engagement object Customer engagement outcome
intent_analysis_result object AI intent analysis and classification
Tasks
get_whatsapp_message
script

Retrieve incoming WhatsApp message details

Task Outputs: {'name': 'message_data', 'value': 'WhatsApp message retrieved'}
get_customer_context_from_crm
script

Retrieve customer information and history from CRM

Task Outputs: {'name': 'customer_context', 'value': 'Customer context retrieved from CRM'}
get_conversation_history
script

Retrieve WhatsApp conversation history for context

Task Outputs: {'name': 'conversation_history', 'value': 'Conversation history retrieved'}
get_product_catalog_from_dynamics
script

Retrieve relevant product information from Dynamics 365

Task Outputs: {'name': 'product_catalog', 'value': 'Product catalog retrieved from Dynamics'}
analyze_message_intent
script

AI-powered analysis of customer message intent and sentiment

Task Outputs: {'name': 'intent_analysis', 'value': 'Message intent analyzed'}
get_product_info
script

Retrieve specific product information for inquiry intent

Task Outputs: {'name': 'product_info', 'value': 'Product information retrieved'}
get_support_context
script

Retrieve support context for complaint intent

Task Outputs: {'name': 'support_context', 'value': 'Support context retrieved'}
get_order_details
script

Retrieve order information for order intent

Task Outputs: {'name': 'order_details', 'value': 'Order details retrieved'}
get_troubleshooting
script

Retrieve troubleshooting information for support intent

Task Outputs: {'name': 'troubleshooting_info', 'value': 'Troubleshooting information retrieved'}
generate_response
script

AI-powered response generation based on intent and context

Task Outputs: {'name': 'generated_response', 'value': 'AI response generated'}
determine_escalation_need
script

Assess if human escalation is needed

Task Outputs: {'name': 'escalation_assessment', 'value': 'Escalation need determined'}
send_whatsapp_response
script

Send AI-generated response via WhatsApp

Task Outputs: {'name': 'whatsapp_response_sent', 'value': 'WhatsApp response sent'}
escalate_to_human
script

Escalate conversation to human agent

Task Outputs: {'name': 'escalation_result', 'value': 'Conversation escalated to human'}
update_conversation_log
script

Log interaction details in CRM system

Task Outputs: {'name': 'conversation_log', 'value': 'Conversation logged in CRM'}
check_new_inquiry
script

Determine if this creates a new inquiry/opportunity

Task Outputs: {'name': 'inquiry_check_result', 'value': 'New inquiry check completed'}
create_crm_inquiry
script

Create new inquiry record in CRM

Task Outputs: {'name': 'crm_inquiry_created', 'value': 'CRM inquiry created'}
schedule_follow_up
script

Schedule appropriate follow-up actions

Task Outputs: {'name': 'follow_up_scheduled', 'value': 'Follow-up actions scheduled'}
Triggers
Webhook Trigger: WhatsApp Message Received
POST /webhook/whatsapp-message
Manual Trigger: Manual Message Processing
YAML Source
id: whatsapp_customer_engagement_workflow
name: WhatsApp Customer Engagement Workflow
tasks:
- id: get_whatsapp_message
  name: Get WhatsApp Message
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\n\n\
    print(\"\U0001F4F1 Retrieving WhatsApp message...\")\n\nmessage_id = \"wamid.HBgLMTIzNDU2Nzg5MDE...\"\
    \nsender_phone = \"+1234567890\"\n\n# Mock WhatsApp message data\nmessage_data\
    \ = {\n    \"message_id\": message_id,\n    \"from\": sender_phone,\n    \"timestamp\"\
    : \"1719331200\",\n    \"type\": \"text\",\n    \"text\": {\n        \"body\"\
    : \"Hi, I'm interested in your CRM solution for my company. We have about 500\
    \ employees and need something that can scale with our growth. Can you tell me\
    \ about pricing and implementation timeline?\"\n    },\n    \"profile\": {\n \
    \       \"name\": \"John Smith\"\n    },\n    \"context\": {\n        \"from\"\
    : sender_phone,\n        \"forwarded\": False,\n        \"frequently_forwarded\"\
    : False\n    },\n    \"message_analysis\": {\n        \"message_length\": 142,\n\
    \        \"language_detected\": \"en\",\n        \"sentiment\": \"positive\",\n\
    \        \"urgency_level\": \"medium\",\n        \"business_context\": {\n   \
    \         \"company_size_mentioned\": \"500 employees\",\n            \"solution_type\"\
    : \"CRM\",\n            \"specific_interests\": [\"pricing\", \"implementation\"\
    , \"scalability\"]\n        }\n    }\n}\n\nprint(f\"\u2705 Message retrieved from\
    \ {message_data['profile']['name']}\")\nprint(f\"   Phone: {message_data['from']}\"\
    )\nprint(f\"   Message: {message_data['text']['body'][:50]}...\")\nprint(f\" \
    \  Sentiment: {message_data['message_analysis']['sentiment']}\")\n\nprint(f\"\
    __OUTPUTS__ {json.dumps(message_data)}\")\n"
  outputs:
  - name: message_data
    value: WhatsApp message retrieved
  packages:
  - json==2.0.9
  - datetime
  description: Retrieve incoming WhatsApp message details
- id: get_customer_context_from_crm
  name: Get Customer Context from CRM
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F50D Retrieving customer\
    \ context from CRM...\")\n\nphone_number = \"+1234567890\"\n\n# Mock CRM customer\
    \ context\ncustomer_context = {\n    \"customer_found\": True,\n    \"customer_id\"\
    : \"CUST_789\",\n    \"customer_name\": \"John Smith\",\n    \"company\": \"TechCorp\
    \ Industries\",\n    \"industry\": \"Technology\",\n    \"company_size\": \"500-1000\"\
    ,\n    \"customer_tier\": \"enterprise\",\n    \"account_status\": \"active_prospect\"\
    ,\n    \"lead_source\": \"website_form\",\n    \"assigned_officer\": \"OFF_001\"\
    ,\n    \"interaction_history\": [\n        {\n            \"date\": \"2025-06-20T14:30:00Z\"\
    ,\n            \"type\": \"email\",\n            \"direction\": \"inbound\",\n\
    \            \"subject\": \"Initial inquiry about CRM solutions\",\n         \
    \   \"outcome\": \"information_sent\"\n        },\n        {\n            \"date\"\
    : \"2025-06-22T10:15:00Z\",\n            \"type\": \"phone_call\",\n         \
    \   \"direction\": \"outbound\",\n            \"duration_minutes\": 15,\n    \
    \        \"outcome\": \"voicemail_left\"\n        }\n    ],\n    \"current_deals\"\
    : [\n        {\n            \"deal_id\": \"DEAL_2025_001234\",\n            \"\
    deal_name\": \"TechCorp CRM Implementation\",\n            \"stage\": \"qualified\"\
    ,\n            \"value\": 125000.00,\n            \"probability\": 0.65,\n   \
    \         \"last_activity\": \"2025-06-22T10:15:00Z\"\n        }\n    ],\n   \
    \ \"preferences\": {\n        \"preferred_contact_method\": \"whatsapp\",\n  \
    \      \"contact_time_preference\": \"business_hours\",\n        \"communication_style\"\
    : \"professional_direct\",\n        \"language\": \"en\"\n    },\n    \"previous_inquiries\"\
    : [\n        {\n            \"date\": \"2025-06-20\",\n            \"topic\":\
    \ \"CRM pricing for enterprise\",\n            \"status\": \"pending_follow_up\"\
    \n        }\n    ]\n}\n\nprint(f\"\u2705 Customer context retrieved for {customer_context['customer_name']}\"\
    )\nprint(f\"   Company: {customer_context['company']}\")\nprint(f\"   Customer\
    \ tier: {customer_context['customer_tier']}\")\nprint(f\"   Active deals: {len(customer_context['current_deals'])}\"\
    )\nprint(f\"   Previous interactions: {len(customer_context['interaction_history'])}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(customer_context)}\")\n"
  outputs:
  - name: customer_context
    value: Customer context retrieved from CRM
  packages:
  - json==2.0.9
  depends_on:
  - get_whatsapp_message
  description: Retrieve customer information and history from CRM
- id: get_conversation_history
  name: Get Conversation History
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\nfrom\
    \ datetime import timedelta\n\nprint(\"\U0001F4AC Retrieving conversation history...\"\
    )\n\nphone_number = \"+1234567890\"\n\n# Mock conversation history\nconversation_history\
    \ = {\n    \"conversation_id\": \"conv_12345\",\n    \"total_messages\": 3,\n\
    \    \"conversation_started\": \"2025-06-20T14:30:00Z\",\n    \"last_activity\"\
    : \"2025-06-25T16:30:00Z\",\n    \"conversation_stage\": \"initial_inquiry\",\n\
    \    \"messages\": [\n        {\n            \"id\": \"msg_001\",\n          \
    \  \"timestamp\": \"2025-06-20T14:30:00Z\",\n            \"from\": \"+1234567890\"\
    ,\n            \"type\": \"text\",\n            \"text\": \"Hello, I'm looking\
    \ for a CRM solution for our company\",\n            \"direction\": \"inbound\"\
    \n        },\n        {\n            \"id\": \"msg_002\",\n            \"timestamp\"\
    : \"2025-06-20T14:35:00Z\",\n            \"from\": \"business_number\",\n    \
    \        \"type\": \"text\",\n            \"text\": \"Hi John! Thanks for reaching\
    \ out. I'd be happy to help you find the right CRM solution. Can you tell me more\
    \ about your company size and specific needs?\",\n            \"direction\": \"\
    outbound\"\n        },\n        {\n            \"id\": \"msg_003\",\n        \
    \    \"timestamp\": \"2025-06-25T16:30:00Z\",\n            \"from\": \"+1234567890\"\
    ,\n            \"type\": \"text\",\n            \"text\": \"Hi, I'm interested\
    \ in your CRM solution for my company. We have about 500 employees and need something\
    \ that can scale with our growth. Can you tell me about pricing and implementation\
    \ timeline?\",\n            \"direction\": \"inbound\"\n        }\n    ],\n  \
    \  \"conversation_analytics\": {\n        \"customer_messages\": 2,\n        \"\
    business_messages\": 1,\n        \"avg_response_time\": \"5 minutes\",\n     \
    \   \"engagement_level\": \"high\",\n        \"sentiment_progression\": [\"neutral\"\
    , \"positive\", \"positive\"],\n        \"topics_discussed\": [\"company_size\"\
    , \"scalability\", \"pricing\", \"implementation\"]\n    },\n    \"context_summary\"\
    : {\n        \"customer_needs\": [\"scalable_crm\", \"enterprise_solution\", \"\
    implementation_support\"],\n        \"information_provided\": [\"initial_greeting\"\
    , \"needs_assessment\"],\n        \"next_expected_topics\": [\"pricing_details\"\
    , \"feature_overview\", \"demo_scheduling\"]\n    }\n}\n\nprint(f\"\u2705 Conversation\
    \ history retrieved\")\nprint(f\"   Total messages: {conversation_history['total_messages']}\"\
    )\nprint(f\"   Engagement level: {conversation_history['conversation_analytics']['engagement_level']}\"\
    )\nprint(f\"   Current stage: {conversation_history['conversation_stage']}\")\n\
    \nprint(f\"__OUTPUTS__ {json.dumps(conversation_history)}\")\n"
  outputs:
  - name: conversation_history
    value: Conversation history retrieved
  packages:
  - json==2.0.9
  depends_on:
  - get_customer_context_from_crm
  description: Retrieve WhatsApp conversation history for context
- id: get_product_catalog_from_dynamics
  name: Get Product Catalog from Dynamics
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F4E6 Retrieving product\
    \ catalog from Dynamics...\")\n\n# Mock product catalog\nproduct_catalog = {\n\
    \    \"products\": [\n        {\n            \"product_id\": \"CRM_ENT_001\",\n\
    \            \"name\": \"CRM Enterprise Edition\",\n            \"category\":\
    \ \"crm_software\",\n            \"description\": \"Complete CRM solution for\
    \ enterprise organizations with advanced analytics and customization\",\n    \
    \        \"target_company_size\": \"500+\",\n            \"pricing\": {\n    \
    \            \"base_price\": 299.99,\n                \"currency\": \"USD\",\n\
    \                \"billing_cycle\": \"monthly\",\n                \"pricing_tiers\"\
    : [\n                    {\n                        \"tier\": \"500-1000 users\"\
    ,\n                        \"price_per_user\": 199.99,\n                     \
    \   \"setup_fee\": 15000.00,\n                        \"annual_discount\": 0.15\n\
    \                    },\n                    {\n                        \"tier\"\
    : \"1000+ users\",\n                        \"price_per_user\": 179.99,\n    \
    \                    \"setup_fee\": 25000.00,\n                        \"annual_discount\"\
    : 0.20\n                    }\n                ]\n            },\n           \
    \ \"key_features\": [\n                \"Unlimited users\",\n                \"\
    Advanced analytics and reporting\",\n                \"Custom workflows\",\n \
    \               \"API integrations\",\n                \"24/7 enterprise support\"\
    ,\n                \"Multi-tenant architecture\"\n            ],\n           \
    \ \"implementation\": {\n                \"typical_timeline\": \"8-12 weeks\"\
    ,\n                \"implementation_cost\": \"25% of license cost\",\n       \
    \         \"training_included\": True,\n                \"data_migration\": True\n\
    \            },\n            \"competitive_advantages\": [\n                \"\
    Superior scalability\",\n                \"Industry-leading uptime (99.9%)\",\n\
    \                \"Advanced AI features\",\n                \"Comprehensive API\
    \ ecosystem\"\n            ]\n        },\n        {\n            \"product_id\"\
    : \"CRM_PRO_002\",\n            \"name\": \"CRM Professional\",\n            \"\
    category\": \"crm_software\",\n            \"description\": \"Professional CRM\
    \ solution for growing businesses\",\n            \"target_company_size\": \"\
    100-500\",\n            \"pricing\": {\n                \"base_price\": 149.99,\n\
    \                \"currency\": \"USD\",\n                \"billing_cycle\": \"\
    monthly\"\n            },\n            \"key_features\": [\n                \"\
    Up to 500 users\",\n                \"Standard reporting\",\n                \"\
    Email integration\",\n                \"Mobile app\"\n            ]\n        }\n\
    \    ],\n    \"recommendations\": {\n        \"best_match\": \"CRM_ENT_001\",\n\
    \        \"match_reasons\": [\n            \"Company size (500 employees) fits\
    \ enterprise tier\",\n            \"Scalability requirements align with enterprise\
    \ features\",\n            \"Growth trajectory suggests need for advanced capabilities\"\
    \n        ],\n        \"alternative_options\": [\"CRM_PRO_002\"],\n        \"\
    upsell_opportunities\": [\n            \"Advanced Analytics Module\",\n      \
    \      \"AI Automation Add-on\"\n        ]\n    }\n}\n\nrecommended_product =\
    \ product_catalog['recommendations']['best_match']\nmain_product = next(p for\
    \ p in product_catalog['products'] if p['product_id'] == recommended_product)\n\
    \nprint(f\"\u2705 Product catalog retrieved\")\nprint(f\"   Total products: {len(product_catalog['products'])}\"\
    )\nprint(f\"   Recommended: {main_product['name']}\")\nprint(f\"   Target size:\
    \ {main_product['target_company_size']}\")\n\nprint(f\"__OUTPUTS__ {json.dumps(product_catalog)}\"\
    )\n"
  outputs:
  - name: product_catalog
    value: Product catalog retrieved from Dynamics
  packages:
  - json==2.0.9
  depends_on:
  - get_conversation_history
  description: Retrieve relevant product information from Dynamics 365
- id: analyze_message_intent
  name: Analyze Message Intent
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F916 Analyzing message\
    \ intent...\")\n\nmessage_content = \"Hi, I'm interested in your CRM solution\
    \ for my company. We have about 500 employees and need something that can scale\
    \ with our growth. Can you tell me about pricing and implementation timeline?\"\
    \n\n# Mock AI intent analysis\nintent_analysis = {\n    \"primary_intent\": \"\
    product_inquiry\",\n    \"confidence_score\": 0.94,\n    \"intent_hierarchy\"\
    : [\n        {\"intent\": \"product_inquiry\", \"confidence\": 0.94},\n      \
    \  {\"intent\": \"pricing_request\", \"confidence\": 0.87},\n        {\"intent\"\
    : \"implementation_question\", \"confidence\": 0.76},\n        {\"intent\": \"\
    scalability_concern\", \"confidence\": 0.69}\n    ],\n    \"sentiment_analysis\"\
    : {\n        \"overall_sentiment\": \"positive\",\n        \"sentiment_score\"\
    : 0.78,\n        \"emotional_indicators\": [\"interest\", \"professional\", \"\
    forward_thinking\"],\n        \"tone_analysis\": \"business_focused\",\n     \
    \   \"urgency_level\": \"medium\"\n    },\n    \"entity_extraction\": {\n    \
    \    \"company_size\": \"500 employees\",\n        \"solution_type\": \"CRM solution\"\
    ,\n        \"key_requirements\": [\"scalability\", \"growth_support\"],\n    \
    \    \"information_needs\": [\"pricing\", \"implementation_timeline\"],\n    \
    \    \"decision_stage\": \"evaluation\",\n        \"budget_indicators\": [\"established_company\"\
    , \"500_employees\"]\n    },\n    \"buying_signals\": {\n        \"signals_detected\"\
    : [\n            \"specific_company_size_mentioned\",\n            \"scalability_requirements_defined\"\
    ,\n            \"implementation_timeline_inquiry\",\n            \"pricing_information_requested\"\
    \n        ],\n        \"buying_stage\": \"consideration\",\n        \"urgency_score\"\
    : 0.65,\n        \"decision_authority\": \"likely_influencer\",\n        \"budget_probability\"\
    : \"high\"\n    },\n    \"conversation_context\": {\n        \"follow_up_to_previous\"\
    : True,\n        \"information_gap\": [\"detailed_pricing\", \"implementation_process\"\
    ],\n        \"customer_education_level\": \"informed\",\n        \"technical_sophistication\"\
    : \"medium\"\n    }\n}\n\nprint(f\"\u2705 Intent analysis completed\")\nprint(f\"\
    \   Primary intent: {intent_analysis['primary_intent']} ({intent_analysis['confidence_score']:.2f})\"\
    )\nprint(f\"   Sentiment: {intent_analysis['sentiment_analysis']['overall_sentiment']}\
    \ ({intent_analysis['sentiment_analysis']['sentiment_score']:.2f})\")\nprint(f\"\
    \   Buying stage: {intent_analysis['buying_signals']['buying_stage']}\")\nprint(f\"\
    \   Buying signals: {len(intent_analysis['buying_signals']['signals_detected'])}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(intent_analysis)}\")\n"
  outputs:
  - name: intent_analysis
    value: Message intent analyzed
  packages:
  - json==2.0.9
  depends_on:
  - get_product_catalog_from_dynamics
  description: AI-powered analysis of customer message intent and sentiment
- id: get_product_info
  name: Get Product Info
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F4CB Retrieving product\
    \ information for inquiry...\")\n\n# Mock detailed product info for response\n\
    product_info = {\n    \"product_focus\": \"CRM Enterprise Edition\",\n    \"relevant_features\"\
    : [\n        {\n            \"feature\": \"Unlimited Users\",\n            \"\
    benefit\": \"Perfect for your 500+ employee company with room to grow\",\n   \
    \         \"relevance\": \"high\"\n        },\n        {\n            \"feature\"\
    : \"Advanced Scalability\",\n            \"benefit\": \"Built to handle enterprise\
    \ growth without performance impact\",\n            \"relevance\": \"high\"\n\
    \        },\n        {\n            \"feature\": \"Custom Workflows\",\n     \
    \       \"benefit\": \"Adapt the system to your unique business processes\",\n\
    \            \"relevance\": \"medium\"\n        }\n    ],\n    \"pricing_summary\"\
    : {\n        \"recommended_tier\": \"500-1000 users\",\n        \"price_per_user\"\
    : 199.99,\n        \"estimated_monthly_cost\": 99995.00,\n        \"setup_fee\"\
    : 15000.00,\n        \"annual_savings\": \"15% discount available\",\n       \
    \ \"roi_estimate\": \"Typically 300% ROI within 18 months\"\n    },\n    \"implementation_details\"\
    : {\n        \"timeline\": \"8-12 weeks for full implementation\",\n        \"\
    phases\": [\n            \"Planning and setup (2 weeks)\",\n            \"Data\
    \ migration (3-4 weeks)\",\n            \"User training (2 weeks)\",\n       \
    \     \"Go-live and support (1-2 weeks)\"\n        ],\n        \"support_included\"\
    : \"Dedicated implementation manager and 24/7 support\",\n        \"training\"\
    : \"Comprehensive user training for all 500 employees\"\n    },\n    \"next_steps\"\
    : [\n        \"Schedule detailed demo\",\n        \"Provide customized pricing\
    \ proposal\",\n        \"Connect with implementation specialist\"\n    ]\n}\n\n\
    print(f\"\u2705 Product information compiled\")\nprint(f\"   Focus product: {product_info['product_focus']}\"\
    )\nprint(f\"   Estimated monthly cost: ${product_info['pricing_summary']['estimated_monthly_cost']:,.2f}\"\
    )\nprint(f\"   Implementation timeline: {product_info['implementation_details']['timeline']}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(product_info)}\")\n"
  outputs:
  - name: product_info
    value: Product information retrieved
  packages:
  - json==2.0.9
  condition: ${intent_analysis.primary_intent} == 'product_inquiry'
  depends_on:
  - analyze_message_intent
  description: Retrieve specific product information for inquiry intent
- id: get_support_context
  name: Get Support Context
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F6E0\uFE0F Retrieving\
    \ support context for complaint...\")\n\n# Mock support context\nsupport_context\
    \ = {\n    \"complaint_type\": \"service_issue\",\n    \"severity\": \"medium\"\
    ,\n    \"related_tickets\": [\n        {\n            \"ticket_id\": \"SUP_2025_001234\"\
    ,\n            \"status\": \"open\",\n            \"created_date\": \"2025-06-20T09:00:00Z\"\
    ,\n            \"issue\": \"Login problems\",\n            \"assigned_agent\"\
    : \"AGENT_001\"\n        }\n    ],\n    \"customer_satisfaction_score\": 3.2,\n\
    \    \"recent_issues\": [\n        \"Authentication delays\",\n        \"Slow\
    \ report generation\"\n    ],\n    \"escalation_needed\": False,\n    \"support_actions\"\
    : [\n        \"Acknowledge complaint\",\n        \"Provide immediate troubleshooting\"\
    ,\n        \"Schedule follow-up call\"\n    ]\n}\n\nprint(f\"\u2705 Support context\
    \ retrieved\")\nprint(f\"   Complaint type: {support_context['complaint_type']}\"\
    )\nprint(f\"   Open tickets: {len(support_context['related_tickets'])}\")\n\n\
    print(f\"__OUTPUTS__ {json.dumps(support_context)}\")\n"
  outputs:
  - name: support_context
    value: Support context retrieved
  packages:
  - json==2.0.9
  condition: ${intent_analysis.primary_intent} == 'complaint'
  depends_on:
  - analyze_message_intent
  description: Retrieve support context for complaint intent
- id: get_order_details
  name: Get Order Details
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F4E6 Retrieving order\
    \ details...\")\n\n# Mock order details\norder_details = {\n    \"recent_orders\"\
    : [\n        {\n            \"order_id\": \"ORD_2025_001234\",\n            \"\
    status\": \"processing\",\n            \"order_date\": \"2025-06-20T00:00:00Z\"\
    ,\n            \"total_amount\": 15000.00,\n            \"items\": [\n       \
    \         {\n                    \"product\": \"CRM Professional License\",\n\
    \                    \"quantity\": 100,\n                    \"unit_price\": 149.99\n\
    \                }\n            ],\n            \"estimated_delivery\": \"2025-07-15T00:00:00Z\"\
    \n        }\n    ],\n    \"order_status_options\": [\n        \"Check order status\"\
    ,\n        \"Modify order\",\n        \"Cancel order\",\n        \"Track delivery\"\
    \n    ],\n    \"payment_information\": {\n        \"payment_method\": \"Corporate\
    \ credit card\",\n        \"payment_status\": \"approved\",\n        \"invoice_sent\"\
    : True\n    }\n}\n\nprint(f\"\u2705 Order details retrieved\")\nprint(f\"   Recent\
    \ orders: {len(order_details['recent_orders'])}\")\n\nprint(f\"__OUTPUTS__ {json.dumps(order_details)}\"\
    )\n"
  outputs:
  - name: order_details
    value: Order details retrieved
  packages:
  - json==2.0.9
  condition: ${intent_analysis.primary_intent} == 'order'
  depends_on:
  - analyze_message_intent
  description: Retrieve order information for order intent
- id: get_troubleshooting
  name: Get Troubleshooting
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F527 Retrieving troubleshooting\
    \ information...\")\n\n# Mock troubleshooting info\ntroubleshooting_info = {\n\
    \    \"common_issues\": [\n        {\n            \"issue\": \"Login problems\"\
    ,\n            \"solution\": \"Clear browser cache and try again\",\n        \
    \    \"success_rate\": 0.85\n        },\n        {\n            \"issue\": \"\
    Slow performance\",\n            \"solution\": \"Check internet connection and\
    \ try during off-peak hours\",\n            \"success_rate\": 0.70\n        },\n\
    \        {\n            \"issue\": \"Data sync issues\",\n            \"solution\"\
    : \"Refresh the page and wait 5 minutes for sync\",\n            \"success_rate\"\
    : 0.90\n        }\n    ],\n    \"self_service_options\": [\n        \"Knowledge\
    \ base articles\",\n        \"Video tutorials\",\n        \"Community forum\"\
    ,\n        \"Live chat support\"\n    ],\n    \"escalation_triggers\": [\n   \
    \     \"Technical complexity high\",\n        \"Customer frustration detected\"\
    ,\n        \"Multiple failed self-service attempts\"\n    ]\n}\n\nprint(f\"\u2705\
    \ Troubleshooting information retrieved\")\nprint(f\"   Common issues: {len(troubleshooting_info['common_issues'])}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(troubleshooting_info)}\")\n"
  outputs:
  - name: troubleshooting_info
    value: Troubleshooting information retrieved
  packages:
  - json==2.0.9
  condition: ${intent_analysis.primary_intent} == 'support'
  depends_on:
  - analyze_message_intent
  description: Retrieve troubleshooting information for support intent
- id: generate_response
  name: Generate Response
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\u270D\uFE0F Generating\
    \ AI response...\")\n\n# Mock AI response generation based on product inquiry\
    \ intent\ngenerated_response = {\n    \"response_type\": \"product_inquiry_response\"\
    ,\n    \"tone\": \"professional_helpful\",\n    \"personalization_level\": \"\
    high\",\n    \"message_text\": \"Hi John! Great to hear from you again. For TechCorp\
    \ with 500 employees, our CRM Enterprise Edition would be perfect - it's designed\
    \ specifically for companies your size with unlimited users and advanced scalability\
    \ features.\\n\\nHere's what you're looking at:\\n\U0001F4B0 Pricing: $199.99/user/month\
    \ (about $100K/month for 500 users)\\n\u23F1\uFE0F Implementation: 8-12 weeks\
    \ with full training included\\n\U0001F4C8 ROI: Most clients see 300% ROI within\
    \ 18 months\\n\\nThe system grows with you - no performance issues as you scale\
    \ beyond 500 employees. Would you like me to schedule a personalized demo to show\
    \ you exactly how it would work for TechCorp?\",\n    \"key_elements\": [\n  \
    \      \"Personal greeting using name and company\",\n        \"Specific product\
    \ recommendation with reasoning\",\n        \"Clear pricing information\",\n \
    \       \"Implementation timeline\",\n        \"ROI value proposition\",\n   \
    \     \"Scalability assurance\",\n        \"Clear call-to-action\"\n    ],\n \
    \   \"call_to_action\": {\n        \"primary\": \"Schedule personalized demo\"\
    ,\n        \"secondary\": \"Request detailed pricing proposal\",\n        \"urgency\"\
    : \"medium\"\n    },\n    \"follow_up_suggestions\": [\n        \"Demo scheduling\"\
    ,\n        \"Detailed proposal preparation\",\n        \"Implementation timeline\
    \ discussion\"\n    ],\n    \"estimated_response_effectiveness\": 0.87,\n    \"\
    expected_customer_actions\": [\n        \"Request demo\",\n        \"Ask follow-up\
    \ questions\",\n        \"Request proposal\"\n    ]\n}\n\nprint(f\"\u2705 Response\
    \ generated\")\nprint(f\"   Response type: {generated_response['response_type']}\"\
    )\nprint(f\"   Tone: {generated_response['tone']}\")\nprint(f\"   Effectiveness\
    \ estimate: {generated_response['estimated_response_effectiveness']:.2f}\")\n\
    print(f\"   Message length: {len(generated_response['message_text'])} characters\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(generated_response)}\")\n"
  outputs:
  - name: generated_response
    value: AI response generated
  packages:
  - json==2.0.9
  depends_on:
  - get_product_info
  - get_support_context
  - get_order_details
  - get_troubleshooting
  description: AI-powered response generation based on intent and context
- id: determine_escalation_need
  name: Determine Escalation Need
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F3AF Determining escalation\
    \ need...\")\n\n# Mock escalation assessment\nescalation_assessment = {\n    \"\
    needs_human_escalation\": False,\n    \"escalation_confidence\": 0.85,\n    \"\
    assessment_factors\": [\n        {\n            \"factor\": \"message_complexity\"\
    ,\n            \"score\": 0.3,\n            \"threshold\": 0.7,\n            \"\
    status\": \"below_threshold\"\n        },\n        {\n            \"factor\":\
    \ \"customer_sentiment\",\n            \"score\": 0.78,\n            \"threshold\"\
    : 0.3,\n            \"status\": \"positive\"\n        },\n        {\n        \
    \    \"factor\": \"technical_complexity\",\n            \"score\": 0.2,\n    \
    \        \"threshold\": 0.6,\n            \"status\": \"low_complexity\"\n   \
    \     },\n        {\n            \"factor\": \"deal_value\",\n            \"score\"\
    : 0.8,\n            \"threshold\": 0.7,\n            \"status\": \"high_value\"\
    \n        },\n        {\n            \"factor\": \"conversation_duration\",\n\
    \            \"score\": 0.2,\n            \"threshold\": 0.8,\n            \"\
    status\": \"short_conversation\"\n        }\n    ],\n    \"escalation_triggers\"\
    : {\n        \"high_value_deal\": True,\n        \"enterprise_customer\": True,\n\
    \        \"complex_technical_query\": False,\n        \"customer_frustration\"\
    : False,\n        \"pricing_negotiation\": False\n    },\n    \"ai_capability_assessment\"\
    : {\n        \"can_handle_query\": True,\n        \"information_complete\": True,\n\
    \        \"response_quality_sufficient\": True,\n        \"follow_up_manageable\"\
    : True\n    },\n    \"recommendation\": \"ai_handled\",\n    \"escalation_reason\"\
    : None,\n    \"monitoring_required\": True,\n    \"escalation_threshold_met\"\
    : False\n}\n\nescalation_needed = escalation_assessment[\"needs_human_escalation\"\
    ]\n\nif escalation_needed:\n    print(f\"\U0001F6A8 Human escalation required\"\
    )\n    print(f\"   Reason: {escalation_assessment.get('escalation_reason', 'Multiple\
    \ factors')}\")\nelse:\n    print(f\"\u2705 AI can handle this query\")\n    print(f\"\
    \   Confidence: {escalation_assessment['escalation_confidence']:.2f}\")\n\nprint(f\"\
    \   High value deal detected: {escalation_assessment['escalation_triggers']['high_value_deal']}\"\
    )\nprint(f\"   Monitoring required: {escalation_assessment['monitoring_required']}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(escalation_assessment)}\")\n"
  outputs:
  - name: escalation_assessment
    value: Escalation need determined
  packages:
  - json==2.0.9
  depends_on:
  - generate_response
  description: Assess if human escalation is needed
- id: send_whatsapp_response
  name: Send WhatsApp Response
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\n\n\
    print(\"\U0001F4E4 Sending WhatsApp response...\")\n\nrecipient_phone = \"+1234567890\"\
    \nmessage_content = \"Hi John! Great to hear from you again. For TechCorp with\
    \ 500 employees, our CRM Enterprise Edition would be perfect - it's designed specifically\
    \ for companies your size with unlimited users and advanced scalability features.\\\
    n\\nHere's what you're looking at:\\n\U0001F4B0 Pricing: $199.99/user/month (about\
    \ $100K/month for 500 users)\\n\u23F1\uFE0F Implementation: 8-12 weeks with full\
    \ training included\\n\U0001F4C8 ROI: Most clients see 300% ROI within 18 months\\\
    n\\nThe system grows with you - no performance issues as you scale beyond 500\
    \ employees. Would you like me to schedule a personalized demo to show you exactly\
    \ how it would work for TechCorp?\"\n\n# Mock WhatsApp response sending\nresponse_result\
    \ = {\n    \"message_id\": \"wamid.HBgLMTIzNDU2Nzg5MDE_response...\",\n    \"\
    recipient\": recipient_phone,\n    \"recipient_name\": \"John Smith\",\n    \"\
    message_status\": \"sent\",\n    \"sent_at\": datetime.now().isoformat(),\n  \
    \  \"delivery_status\": \"delivered\",\n    \"message_type\": \"text\",\n    \"\
    character_count\": len(message_content),\n    \"estimated_delivery\": \"immediate\"\
    ,\n    \"conversation_id\": \"conv_12345\",\n    \"ai_handled\": True,\n    \"\
    response_time_seconds\": 8.5,\n    \"campaign_tracking\": {\n        \"campaign_type\"\
    : \"ai_customer_engagement\",\n        \"intent_addressed\": \"product_inquiry\"\
    ,\n        \"personalization_level\": \"high\",\n        \"expected_engagement\"\
    : \"high\"\n    }\n}\n\nprint(f\"\u2705 WhatsApp response sent to {response_result['recipient_name']}\"\
    )\nprint(f\"   Message ID: {response_result['message_id']}\")\nprint(f\"   Status:\
    \ {response_result['message_status']}\")\nprint(f\"   Response time: {response_result['response_time_seconds']}\
    \ seconds\")\nprint(f\"   Character count: {response_result['character_count']}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(response_result)}\")\n"
  outputs:
  - name: whatsapp_response_sent
    value: WhatsApp response sent
  packages:
  - json==2.0.9
  condition: ${escalation_assessment.needs_human_escalation} == false
  depends_on:
  - determine_escalation_need
  description: Send AI-generated response via WhatsApp
- id: escalate_to_human
  name: Escalate to Human
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\n\n\
    print(\"\U0001F6A8 Escalating to human agent...\")\n\n# Mock human escalation\n\
    escalation_result = {\n    \"escalation_id\": \"ESC_2025_WA_001234\",\n    \"\
    customer_phone\": \"+1234567890\",\n    \"customer_name\": \"John Smith\",\n \
    \   \"escalation_reason\": \"high_value_enterprise_inquiry\",\n    \"urgency_level\"\
    : \"high\",\n    \"escalated_at\": datetime.now().isoformat(),\n    \"assigned_agent\"\
    : \"AGENT_001\",\n    \"agent_name\": \"Sarah Johnson\",\n    \"estimated_response_time\"\
    : \"15 minutes\",\n    \"escalation_context\": {\n        \"conversation_summary\"\
    : \"Enterprise customer inquiry about CRM for 500 employees, pricing and implementation\
    \ questions\",\n        \"customer_tier\": \"enterprise\",\n        \"deal_potential\"\
    : 125000.00,\n        \"previous_interactions\": 3,\n        \"ai_assessment\"\
    : \"high_value_opportunity_requiring_personal_attention\"\n    },\n    \"handover_message\"\
    : \"Hi John! I'm connecting you with Sarah Johnson, our enterprise specialist,\
    \ who can provide detailed pricing and implementation planning for TechCorp. She'll\
    \ be with you shortly!\",\n    \"agent_briefing\": {\n        \"customer_background\"\
    : \"Existing prospect, 500-employee tech company\",\n        \"current_need\"\
    : \"CRM Enterprise pricing and implementation timeline\",\n        \"recommended_approach\"\
    : \"consultative_sales_focus_on_scalability_and_roi\",\n        \"next_actions\"\
    : [\"detailed_needs_assessment\", \"custom_proposal_preparation\", \"demo_scheduling\"\
    ]\n    }\n}\n\nprint(f\"\u2705 Escalated to {escalation_result['agent_name']}\"\
    )\nprint(f\"   Escalation ID: {escalation_result['escalation_id']}\")\nprint(f\"\
    \   Urgency: {escalation_result['urgency_level']}\")\nprint(f\"   ETA: {escalation_result['estimated_response_time']}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(escalation_result)}\")\n"
  outputs:
  - name: escalation_result
    value: Conversation escalated to human
  packages:
  - json==2.0.9
  condition: ${escalation_assessment.needs_human_escalation} == true
  depends_on:
  - determine_escalation_need
  description: Escalate conversation to human agent
- id: update_conversation_log
  name: Update Conversation Log
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\n\n\
    print(\"\U0001F4DD Updating conversation log...\")\n\n# Mock conversation logging\n\
    conversation_log = {\n    \"log_id\": \"LOG_2025_WA_001234\",\n    \"customer_id\"\
    : \"CUST_789\",\n    \"interaction_type\": \"whatsapp\",\n    \"interaction_date\"\
    : datetime.now().isoformat(),\n    \"direction\": \"inbound\",\n    \"channel\"\
    : \"whatsapp\",\n    \"duration_seconds\": 8.5,\n    \"ai_handled\": True,\n \
    \   \"escalated\": False,\n    \"interaction_summary\": {\n        \"customer_message\"\
    : \"CRM inquiry for 500-employee company, pricing and implementation questions\"\
    ,\n        \"intent_classified\": \"product_inquiry\",\n        \"response_provided\"\
    : \"Detailed CRM Enterprise information with pricing, timeline, and demo offer\"\
    ,\n        \"outcome\": \"information_provided\",\n        \"next_expected_action\"\
    : \"demo_request_or_follow_up_questions\"\n    },\n    \"sentiment_analysis\"\
    : {\n        \"customer_sentiment\": \"positive\",\n        \"satisfaction_predicted\"\
    : 0.85,\n        \"engagement_level\": \"high\"\n    },\n    \"business_impact\"\
    : {\n        \"lead_score_change\": \"+5\",\n        \"deal_progression\": \"\
    information_stage_to_consideration\",\n        \"opportunity_value\": 125000.00,\n\
    \        \"conversion_probability\": 0.68\n    },\n    \"ai_performance\": {\n\
    \        \"response_time\": 8.5,\n        \"intent_accuracy\": 0.94,\n       \
    \ \"response_quality_score\": 0.87,\n        \"escalation_avoidance\": True\n\
    \    },\n    \"follow_up_actions\": [\n        {\n            \"action\": \"monitor_for_response\"\
    ,\n            \"timeline\": \"24_hours\",\n            \"automated\": True\n\
    \        },\n        {\n            \"action\": \"prepare_demo_materials\",\n\
    \            \"timeline\": \"if_requested\",\n            \"automated\": False\n\
    \        }\n    ]\n}\n\nprint(f\"\u2705 Conversation logged\")\nprint(f\"   Log\
    \ ID: {conversation_log['log_id']}\")\nprint(f\"   AI handled: {conversation_log['ai_handled']}\"\
    )\nprint(f\"   Customer sentiment: {conversation_log['sentiment_analysis']['customer_sentiment']}\"\
    )\nprint(f\"   Opportunity value: ${conversation_log['business_impact']['opportunity_value']:,.2f}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(conversation_log)}\")\n"
  outputs:
  - name: conversation_log
    value: Conversation logged in CRM
  packages:
  - json==2.0.9
  depends_on:
  - send_whatsapp_response
  - escalate_to_human
  description: Log interaction details in CRM system
- id: check_new_inquiry
  name: Check New Inquiry
  type: script
  script: "#!/usr/bin/env python3\nimport json\n\nprint(\"\U0001F50D Checking if new\
    \ inquiry should be created...\")\n\n# Mock new inquiry assessment\nnew_inquiry_check\
    \ = {\n    \"creates_new_inquiry\": True,\n    \"inquiry_criteria_met\": [\n \
    \       \"specific_product_interest_expressed\",\n        \"company_size_and_requirements_defined\"\
    ,\n        \"pricing_information_requested\",\n        \"implementation_timeline_discussed\"\
    \n    ],\n    \"existing_inquiries\": [\n        {\n            \"inquiry_id\"\
    : \"INQ_2025_001234\",\n            \"status\": \"pending_follow_up\",\n     \
    \       \"created_date\": \"2025-06-20\",\n            \"topic\": \"Initial CRM\
    \ interest\"\n        }\n    ],\n    \"inquiry_relationship\": \"follow_up_to_existing\"\
    ,\n    \"should_create_new\": True,\n    \"reason\": \"Significant progression\
    \ from initial interest to specific requirements and pricing inquiry\"\n}\n\n\
    creates_inquiry = new_inquiry_check[\"creates_new_inquiry\"]\n\nif creates_inquiry:\n\
    \    print(f\"\u2705 New inquiry should be created\")\n    print(f\"   Reason:\
    \ {new_inquiry_check['reason']}\")\nelse:\n    print(f\"\u2139\uFE0F No new inquiry\
    \ needed\")\n\nprint(f\"   Existing inquiries: {len(new_inquiry_check['existing_inquiries'])}\"\
    )\n\nprint(f\"__OUTPUTS__ {json.dumps(new_inquiry_check)}\")\n"
  outputs:
  - name: inquiry_check_result
    value: New inquiry check completed
  packages:
  - json==2.0.9
  depends_on:
  - update_conversation_log
  description: Determine if this creates a new inquiry/opportunity
- id: create_crm_inquiry
  name: Create CRM Inquiry
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\n\n\
    print(\"\U0001F4CB Creating new CRM inquiry...\")\n\n# Mock CRM inquiry creation\n\
    crm_inquiry = {\n    \"inquiry_id\": \"INQ_2025_005678\",\n    \"customer_id\"\
    : \"CUST_789\",\n    \"customer_phone\": \"+1234567890\",\n    \"customer_email\"\
    : \"john.smith@techcorp.com\",\n    \"inquiry_type\": \"product_interest\",\n\
    \    \"source\": \"whatsapp\",\n    \"priority\": \"high\",\n    \"subject\":\
    \ \"CRM Enterprise Solution for 500 Employees\",\n    \"description\": \"Customer\
    \ interested in CRM Enterprise Edition for 500-employee technology company. Specific\
    \ questions about pricing ($199.99/user/month tier) and implementation timeline\
    \ (8-12 weeks). Company name: TechCorp Industries.\",\n    \"products_of_interest\"\
    : [\"CRM_ENT_001\"],\n    \"customer_context\": {\n        \"company_size\": \"\
    500\",\n        \"industry\": \"technology\",\n        \"current_solution\": \"\
    unknown\",\n        \"scalability_important\": True,\n        \"budget_range\"\
    : \"enterprise_level\"\n    },\n    \"ai_analysis\": {\n        \"intent_confidence\"\
    : 0.94,\n        \"urgency_score\": 0.65,\n        \"budget_indicators\": [\"\
    enterprise\", \"500_employees\", \"scalability_focus\"],\n        \"buying_stage\"\
    : \"consideration\",\n        \"conversion_probability\": 0.68\n    },\n    \"\
    created_at\": datetime.now().isoformat(),\n    \"assigned_to\": \"TEAM_ENTERPRISE_SALES\"\
    ,\n    \"estimated_response_time\": \"2 hours\",\n    \"follow_up_sequence\":\
    \ [\n        {\n            \"step\": 1,\n            \"action\": \"send_detailed_proposal\"\
    ,\n            \"scheduled_for\": (datetime.now()).isoformat(),\n            \"\
    owner\": \"sales_team\"\n        },\n        {\n            \"step\": 2,\n   \
    \         \"action\": \"schedule_demo_call\",\n            \"scheduled_for\":\
    \ \"on_customer_request\",\n            \"owner\": \"demo_specialist\"\n     \
    \   }\n    ],\n    \"related_records\": {\n        \"customer_id\": \"CUST_789\"\
    ,\n        \"existing_deal\": \"DEAL_2025_001234\",\n        \"conversation_log\"\
    : \"LOG_2025_WA_001234\"\n    }\n}\n\nprint(f\"\u2705 CRM inquiry created\")\n\
    print(f\"   Inquiry ID: {crm_inquiry['inquiry_id']}\")\nprint(f\"   Priority:\
    \ {crm_inquiry['priority']}\")\nprint(f\"   Subject: {crm_inquiry['subject']}\"\
    )\nprint(f\"   Assigned to: {crm_inquiry['assigned_to']}\")\nprint(f\"   Conversion\
    \ probability: {crm_inquiry['ai_analysis']['conversion_probability']:.2f}\")\n\
    \nprint(f\"__OUTPUTS__ {json.dumps(crm_inquiry)}\")\n"
  outputs:
  - name: crm_inquiry_created
    value: CRM inquiry created
  packages:
  - json==2.0.9
  condition: ${inquiry_check_result.creates_new_inquiry} == true
  depends_on:
  - check_new_inquiry
  description: Create new inquiry record in CRM
- id: schedule_follow_up
  name: Schedule Follow-up
  type: script
  script: "#!/usr/bin/env python3\nimport json\nfrom datetime import datetime\nfrom\
    \ datetime import timedelta\n\nprint(\"\U0001F4C5 Scheduling follow-up actions...\"\
    )\n\n# Mock follow-up scheduling\nfollow_up_schedule = {\n    \"follow_up_id\"\
    : \"FOLLOWUP_2025_001234\",\n    \"customer_id\": \"CUST_789\",\n    \"conversation_id\"\
    : \"conv_12345\",\n    \"follow_up_type\": \"whatsapp_engagement_follow_up\",\n\
    \    \"scheduled_actions\": [\n        {\n            \"action_id\": \"ACTION_001\"\
    ,\n            \"action_type\": \"response_monitoring\",\n            \"description\"\
    : \"Monitor for customer response to CRM Enterprise information\",\n         \
    \   \"scheduled_for\": datetime.now().isoformat(),\n            \"duration_hours\"\
    : 24,\n            \"automated\": True,\n            \"trigger_condition\": \"\
    no_customer_response_within_24h\"\n        },\n        {\n            \"action_id\"\
    : \"ACTION_002\",\n            \"action_type\": \"proactive_follow_up\",\n   \
    \         \"description\": \"Send follow-up message if no response received\"\
    ,\n            \"scheduled_for\": (datetime.now() + timedelta(hours=48)).isoformat(),\n\
    \            \"automated\": True,\n            \"message_template\": \"demo_offer_follow_up\"\
    ,\n            \"condition\": \"no_response_received\"\n        },\n        {\n\
    \            \"action_id\": \"ACTION_003\",\n            \"action_type\": \"sales_team_notification\"\
    ,\n            \"description\": \"Notify enterprise sales team of high-value opportunity\"\
    ,\n            \"scheduled_for\": (datetime.now() + timedelta(hours=2)).isoformat(),\n\
    \            \"automated\": True,\n            \"recipient\": \"TEAM_ENTERPRISE_SALES\"\
    \n        }\n    ],\n    \"escalation_rules\": [\n        {\n            \"condition\"\
    : \"no_response_after_72_hours\",\n            \"action\": \"escalate_to_sales_manager\"\
    ,\n            \"priority\": \"medium\"\n        },\n        {\n            \"\
    condition\": \"negative_sentiment_detected\",\n            \"action\": \"immediate_human_intervention\"\
    ,\n            \"priority\": \"high\"\n        }\n    ],\n    \"success_metrics\"\
    : {\n        \"target_response_rate\": 0.75,\n        \"target_demo_conversion\"\
    : 0.40,\n        \"target_proposal_acceptance\": 0.60\n    }\n}\n\nprint(f\"\u2705\
    \ Follow-up actions scheduled\")\nprint(f\"   Follow-up ID: {follow_up_schedule['follow_up_id']}\"\
    )\nprint(f\"   Scheduled actions: {len(follow_up_schedule['scheduled_actions'])}\"\
    )\n\nfor action in follow_up_schedule['scheduled_actions']:\n    print(f\"   \u2022\
    \ {action['action_type']}: {action['description']}\")\n\nprint(f\"__OUTPUTS__\
    \ {json.dumps(follow_up_schedule)}\")\n"
  outputs:
  - name: follow_up_scheduled
    value: Follow-up actions scheduled
  packages:
  - json==2.0.9
  depends_on:
  - create_crm_inquiry
  - check_new_inquiry
  description: Schedule appropriate follow-up actions
inputs:
- name: message_id
  type: string
  default: wamid.HBgLMTIzNDU2Nzg5MDE...
  description: WhatsApp message ID from webhook
- name: sender_phone
  type: string
  default: '+1234567890'
  description: Customer phone number
outputs:
  escalation_details:
    type: object
    source: escalate_to_human
    description: Human escalation details if applicable
  message_processing:
    type: object
    source: get_whatsapp_message
    description: WhatsApp message processing results
  conversation_record:
    type: object
    source: update_conversation_log
    description: Complete conversation log and follow-up schedule
  customer_engagement:
    type: object
    source: send_whatsapp_response
    description: Customer engagement outcome
  intent_analysis_result:
    type: object
    source: analyze_message_intent
    description: AI intent analysis and classification
version: '1.0'
triggers:
- name: WhatsApp Message Received
  path: /webhook/whatsapp-message
  type: webhook
  config:
    method: POST
    headers:
    - name: Content-Type
      value: application/json
      required: true
    - name: X-Hub-Signature
      value: webhook_signature
      required: true
    authentication: none
  description: Triggered when new WhatsApp message is received
  input_mapping:
  - webhook_field: entry[0].changes[0].value.messages[0].id
    workflow_input: message_id
  - webhook_field: entry[0].changes[0].value.messages[0].from
    workflow_input: sender_phone
- name: Manual Message Processing
  type: manual
  description: Manually process WhatsApp message
description: Automated WhatsApp customer engagement with AI-powered intent analysis
  and response generation
Execution ID Status Started Duration Actions
3f8ca734... COMPLETED 2025-07-04
15:14:26
N/A View
f61edea2... COMPLETED 2025-07-02
11:12:59
N/A View
b2e8ce19... COMPLETED 2025-07-02
11:04:42
N/A View
6428d13b... COMPLETED 2025-07-02
05:26:01
N/A View
976e850a... COMPLETED 2025-07-01
19:03:18
N/A View