Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Go to Haptik Website
  • Contact Us
  • Home
  • Developer Guides
  • Code Step Integration

Implementing API Failure Alerting Mechanism

Written by Hitesh Singla

Updated on November 24th, 2022

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
    Build Deploy Analyse Manage Account Bot Deactivation
  • Bot Building
    Essentials Smart Skills Steps User Messages Bot Responses Entities Connections Customisations User feedback collection Testing Whatsapp Bots NLU Bot Maintenance
  • Smart Agent Chat
    Set up Admin Settings MyChats Section (Agent Inbox) Live Traffic Section Teams Section Archives Section Analytics Plans on Smart Agent Chat
  • Conversation Design
    Design Basics Design Guides Designing for Platforms Designing WhatsApp Bots
  • Developer Guides
    Code Step Integration Static Step Integration Shopify Integration SETU Integration Exotel Integration CIBIL integration Freshdesk KMS Integration PayU Integration Zendesk Guide Integration Twilio Integration Razorpay Integration LeadSquared Integration USU(Unymira) Integration Helo(VivaConnect) Integration Salesforce KMS Integration Stripe Integration PayPal Integration CleverTap Integration Fynd Integration HubSpot Integration Magento Integration WooCommerce Integration Microsoft Dynamics 365 Integration
  • Deployment
    Web SDK WhatsApp Facebook Instagram Sunshine Conversation LINE Google Business Messages Telegram MS Teams Bot as an API iOS SDK Android SDK
  • External Agent Tool Setup
    Zendesk Chat Salesforce Service Cloud Freshchat Zoho NICE CXOne Gorgias
  • Analytics & Reporting
    Intelligent Analytics
  • Notifications
    SMS Notifications Success Measurement
  • Commerce Plus
    Catalog Integration Bot Building Guide Channel Deployments Unified ML Pipeline Documentation
  • Troubleshooting Guides
    Error Messages FAQs
  • Release Notes
+ More

Follow the below steps to integrate the custom haptik_requests library in Code Nodes to capture API metadata.

  1. Import class inside custom package at top the of file as: 

from haptik_code_library.haptik_requests import HaptikRequests
  1. Create object of class HaptikRequests as haptik_requests. 

haptik_requests = HaptikRequests()
  1. Replace all occurrences of requests-library with haptik_requests.
    I. Existing Implementation:

response = requests.get("https://mock.codes/200")

 II. New Implementation:

response = haptik_requests.get("https://mock.codes/200")

        To track timeout errors, pass timeout parameters with value in seconds.

response = haptik_requests.get(url_1, timeout=0.001)
  1. Add decorator add_api_metadata_to_response() on top of main()function. Here, the main() function gets called automatically when code-node loads. When the response is returned from the main() function, the decorator appends API-metadata with the key to response. For example, main() contains the following:

@haptik_requests.add_api_metadata_to_response()
def main(event, context):
    # main method body and business logic
    u1 = "https://mock.codes/200"
    u2 = "https://mock.codes/300"
    u3 = "https://mock.codes/400"
    u4 = "https://mock.codes/500"
    response = haptik_requests.get(u1)
    response = haptik_requests.get(u2)
    response = haptik_requests.get(u3)
    response = haptik_requests.get(u4)
    response = haptik_requests.get(u1, timeout=0.001)
    final_response = {}
    response = {
        'statusCode': 200,
        'body': json.dumps(final_response),
        'headers': {'Content-Type': 'application/json'}
    }
    return response

As we have made 5 API-calls to 5 different URLs, metadata of each API-call will be appended as a dictionary and final api_metadata will be a list of multiple dictionaries, added in response and returned by decorator. Thus, lambda-response returned to haptik_api service without decorator on main() is:

response = {
    "statusCode": 200,
    "body": {},
    "headers": {
        "Content-Type": "application/json"
    }
}

This feature is supported for the below mentioned integration types:

  1. External API Integration
  2. Enterprise service level API Integration

However, this feature is not supported for internal API Integration.

Once the above mentioned changes are done, the feature needs to be enabled from the feature toggle dashboard using the business via name.

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Using "conversation_details" Variable
  • How to Display Output Using Output Step
  • Using External Packages in Code Step
  • What is Code Step? How to Use Code Step?

Platform

  • Conversation Studio
  • Smart Skills
  • Advanced NLU
  • Intelligent Analytics
  • Omnichannel
  • Smart Agent Chat
  • Enterprise Security
  • Integrations

Solutions

  • Conversational Commerce
  • Lead Generation
  • Customer Care
  • WhatsApp
  • Conversational IVR
  • Google Business Messages

Industries

  • Retail/ E-Commerce
  • Financial Services
  • Travel & Hospitality
  • Telecom

Knowledge

  • ROI Calculator
  • Reports & Research
  • Case Studies
  • Webinars
  • ISAT
  • Tech Blog
  • Business Blog
  • Resources
  • Haptik v/s Yellow
  • Haptik v/s Liveperson
  • Haptik v/s IBM Watson
  • Haptik v/s Verloop
  • Conversations on AI

Company

  • Why Haptik
  • About Us
  • Careers
  • News & Media
  • Awards & Recognition
  • Contact Us
  • Partnerships
  • Investor Relations

Subscribe

Sign up to recieve the latest updates

Find us on

  • Twitter-footer
  • Linkedin-footer
  • YT-footer
  • Insta-footer
  • G2-footer
  • Facebook-footer

Knowledge Base Software powered by Helpjuice

Copyright © jio Haptik Technology Limited 2021 | Data Security & Privacy Policy | GDPR

North America | Asia Pacific | Africa | enterprise@haptik.ai

Definition by Author

0
0