Search code examples
chatbotaws-lex

Calling internal systems (behind firewall) from AWS Lex


I have created an AWS Lex chatbot and now I have to query an internal JIRA for answering certain questions. Can I do this in AWS Lex. I tried using AWS Lambda, but am not able to communicate with internal systems.

Or are there other chatbot engine which would allow me to do this, maybe like call the configured bot as an API per utterance.


Solution

  • Figured out an alternative. Looks like AWS Lex doesn't allow interacting with internal systems unless we explicitly open up the port. I have decided to use Microsoft LUIS. This allows for calling Intent identification from an internal system as an API.

    Following Python code allows me to connect to a configured LUIS service from my local system.

       ########### Python 3.6 #############
    import requests
    
    headers = {
        # Request headers
        'Ocp-Apim-Subscription-Key': 'xxxxxxxxxxxxxxx',
    }
    
    params ={
        # Query parameter
        'q': 'Can I book a travel ticket from LA to Chicago',
        # Optional request parameters, set to default values
        'timezoneOffset': '0',
        'verbose': 'true',
        'spellCheck': 'false',
        'staging': 'true',
    }
    
    try:
        r = requests.get('https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/XXX-XXX-XXX-XXX',headers=headers, params=params)
        print(r.json())
    
    except Exception as e:
        print("[Errno {0}] {1}".format(e.errno, e.strerror))