Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change AWS Lambda content type from Plain text to html

Tags:

node.js

I want to display on my chatbot the link.

message: { contentType: 'PlainText', content:"<a href="www.google.com">Test Result</a>" },

html tag displays as it is. How can I display the content as html?

like image 435
Meshi Avatar asked Sep 12 '17 08:09

Meshi


People also ask

Can AWS Lambda return HTML?

The Lambda Placeholder Create a simple Lambda function that returns an HTML string. Log into to the AWS Console and navigate to the Lambda service. Create a new Lambda function and select the hello-world template.

How can you change between different versions of an AWS Lambda function?

Open the Functions page of the Lambda console. Choose a function and then choose Versions. On the versions configuration page, choose Publish new version. (Optional) Enter a version description.

How do I change the Lambda code in AWS?

On the Code tab, for Code entry type, choose to edit the code in the browser, upload a . zip file, or upload a file from Amazon S3. Choose either Save or Save and test. Choose Actions, and choose Publish new version.

How do you get the request body in Lambda?

If you are using a Lambda Proxy Integration, you need to use JSON. parse(event. body) for JavaScript or json. loads(event["body"]) for Python.


1 Answers

For those that are using the serverless framework, you can configure the content-type of your function's response in your serverless.yml file, for example:

  downloadImage:
    handler: lib/client-app-services.downloadImage
    events:
     - http:
        path: client/images/{filename}
        method: get
        cors: true
        integration: lambda
        response:
          headers:
            Content-Type: "'image/jpeg'"
            Cache-Control: "'max-age=120'"
like image 119
Keith Coughtrey Avatar answered Oct 02 '22 01:10

Keith Coughtrey