{"id":13103,"date":"2020-10-06T11:45:15","date_gmt":"2020-10-06T02:45:15","guid":{"rendered":"https:\/\/sendgrid.kke.co.jp\/blog\/?p=13103"},"modified":"2020-10-06T12:11:12","modified_gmt":"2020-10-06T03:11:12","slug":"sendgrid%e3%81%a8node-js%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6fax%e3%82%92%e3%83%a1%e3%83%bc%e3%83%ab%e3%81%a8%e3%81%97%e3%81%a6%e8%bb%a2%e9%80%81%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/sendgrid.kke.co.jp\/blog\/?p=13103","title":{"rendered":"SendGrid\u3068Node.js\u3092\u4f7f\u3063\u3066FAX\u3092\u30e1\u30fc\u30eb\u3068\u3057\u3066\u8ee2\u9001\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/header.png\" alt=\"FAX\u3092\u30e1\u30fc\u30eb\u3068\u3057\u3066\u8ee2\u9001\u3059\u308b\u65b9\u6cd5\" width=\"100%\" class=\"aligncenter size-full wp-image-13124\" srcset=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/header.png 592w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/header-300x185.png 300w\" sizes=\"(max-width: 592px) 100vw, 592px\" \/><\/p>\n<blockquote>\n<p>\u3053\u306e\u8a18\u4e8b\u306f <a href=\"https:\/\/www.twilio.com\/blog\/fax-email-sendgrid-nodejs\" target=\"_blank\">Forward fax to email with SendGrid and Node.js<\/a> \u306e\u6284\u8a33\u3067\u3059\u3002<\/p>\n<\/blockquote>\n<p>2020\u5e74\u306e\u4eca\u3001FAX\u3092\u53d7\u4fe1\u3057\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u3002\u305d\u3093\u306a\u6642\u3042\u306a\u305f\u306a\u3089\u3069\u3046\u3057\u307e\u3059\u304b\uff1fFAX\u6a5f\u3092\u8cfc\u5165\u3057\u3066\u3001\u96fb\u8a71\u56de\u7dda\u306b\u63a5\u7d9a\u3057\u3001\u81ea\u5206\u306eFAX\u756a\u53f7\u3092\u76f8\u624b\u306b\u77e5\u3089\u305b\u308b\u3001\u307f\u305f\u3044\u306a\u3053\u3068\u306f\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002\u3067\u3082\u3001\u4eca\u306f2020\u5e74\u3067\u3059\u3002\u6614\u3068\u306f\u9055\u3046\u672a\u6765\u306b\u751f\u304d\u3066\u3044\u308b\u306e\u3067\u3059\u304b\u3089\u3001Node.js\u3068\u3044\u304f\u3064\u304b\u306eAPI\u3092\u4f7f\u3063\u3066\u3001FAX\u3092\u30e1\u30fc\u30eb\u306b\u5909\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/twilio-cms-prod.s3.amazonaws.com\/original_images\/G3k0Sh4k3kYe9DHRPsFOIEs3Phb9Z1Mt-GDXtN6VzCIRyCWiwgbpmk3R6MXgRtdjkFehJwOkkVGCCa\" alt=\"FAX\" width=\"50%\" class=\"aligncenter size-full wp-image-xxxxx\" \/><\/p>\n<p>\u3053\u3053\u3067\u5fc5\u8981\u306a\u306e\u306f\u3001<a href=\"https:\/\/www.twilio.com\/try-twilio\" rel=\"noopener\" target=\"_blank\">Twilio\u30a2\u30ab\u30a6\u30f3\u30c8<\/a>\u3068<a href=\"https:\/\/sendgrid.kke.co.jp\/app?p=signup.index\" rel=\"noopener\" target=\"_blank\">SendGrid\u30a2\u30ab\u30a6\u30f3\u30c8<\/a>\u3067\u3059\u3002\u3042\u3068\u306f\u4eca\u56de\u69cb\u7bc9\u3059\u308bFAX\uff0f\u30e1\u30fc\u30eb\u5909\u63db\u30a2\u30d7\u30ea\u306b\u3088\u308a\u5931\u308f\u308c\u308b\u3001<a href=\"https:\/\/www.youtube.com\/watch?v=XC3uDuRXJyA\" rel=\"noopener\" target=\"_blank\">\u3053\u306eFAX\u306e\u30ce\u30a4\u30ba\u97f3<\/a>\u3082\u304a\u5fd8\u308c\u305a\u306b\u3002<\/p>\n<h3>FAX\u306e\u53d7\u4fe1<\/h3>\n<p>\u4eca\u56de\u306f\u3001\u30b4\u30c4\u3044FAX\u6a5f\u3067\u306f\u306a\u304f\u3001Twilio\u306e\u756a\u53f7\u3092\u4f7f\u3063\u3066FAX\u3092\u53d7\u4fe1\u3057\u307e\u3059\u3002\u5909\u63db\u30a2\u30d7\u30ea\u3092\u69cb\u7bc9\u3059\u308b\u305f\u3081\u306b\u3001FAX\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308bTwilio\u756a\u53f7\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<a href=\"http:\/\/twilio.com\/console\" rel=\"noopener\" target=\"_blank\">Twilio\u30a2\u30ab\u30a6\u30f3\u30c8<\/a>\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3001<a href=\"https:\/\/www.twilio.com\/console\/phone-numbers\/search\" rel=\"noopener\" target=\"_blank\">\u65b0\u898f\u3067\u8cfc\u5165<\/a>\u3059\u308b\u304b<a href=\"https:\/\/www.twilio.com\/console\/phone-numbers\/incoming\" rel=\"noopener\" target=\"_blank\">\u65e2\u306b\u6301\u3063\u3066\u3044\u308b\u756a\u53f7<\/a>\u3092\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4ee5\u4e0b\u306e\u30a2\u30a4\u30b3\u30f3\u304cFAX\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/nQIhmVPBdTpbLsB-58rra_bGRNZpKkyuOCEpt9CzpOw0AC.width-500.png\" alt=\"FAX\u306e\u30a2\u30a4\u30b3\u30f3\" width=\"35%\" class=\"aligncenter size-full wp-image-13105\" srcset=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/nQIhmVPBdTpbLsB-58rra_bGRNZpKkyuOCEpt9CzpOw0AC.width-500.png 256w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/nQIhmVPBdTpbLsB-58rra_bGRNZpKkyuOCEpt9CzpOw0AC.width-500-150x150.png 150w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/p>\n<p>\u756a\u53f7\u306e\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u3001Webhook\u3092\u53d7\u4fe1\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002FAX\u306fSMS\u3068\u4f3c\u305f\u3088\u3046\u306a\u52d5\u304d\u3092\u3059\u308b\u3068\u601d\u308f\u308c\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u5b9f\u306f\u97f3\u58f0\u901a\u8a71\u306b\u8fd1\u3044\u3082\u306e\u3067\u3059\u3002\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u306f2\u7a2e\u985e\u306eWebhook\u3092\u53d7\u4fe1\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u30021\u3064\u76ee\u306eWebhook\u3067\u3001FAX\u306e\u53d7\u4fe1\u3082\u3057\u304f\u306f\u62d2\u5426\u306e\u9078\u629e\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001TwilML\u5185\u306everb\u3067\u3001<span style=\"background-color:#d3d3d3\">&lt;Receive&gt;<\/span>\uff08\u53d7\u4fe1\uff09\u3082\u3057\u304f\u306f<span style=\"background-color:#d3d3d3\">&lt;Reject&gt;<\/span>\uff08\u62d2\u5426\uff09\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u7740\u4fe1\u3057\u305fFAX\u3092\u62d2\u5426\u3059\u308b\u3068\u63a5\u7d9a\u306f\u5207\u65ad\u3055\u308c\u307e\u3059\u3002\u4e00\u65b9\u3001\u53d7\u4fe1\u3092\u9078\u629e\u3059\u308b\u3068\u3001Twilio\u304c\u96fb\u8a71\u306b\u51fa\u3066\u3001\u3042\u306a\u305f\u306e\u4ee3\u308f\u308a\u306bFAX\u3092\u53d7\u4fe1\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u884c\u3046\u306b\u306f\u3001<span style=\"background-color:#d3d3d3\">&lt;Receive&gt;<\/span>\u30bf\u30b0\u306eaction\u5c5e\u6027\u306b2\u3064\u76ee\u306eWebhook\u306eURL\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>2\u3064\u76ee\u306eWebhook\u306f\u3001FAX\u3092PDF\u3068\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3001\u3053\u308c\u3092\u30e1\u30fc\u30eb\u3068\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u30012\u3064\u76ee\u306eWebhook\u306e\u53d7\u4fe1\u74b0\u5883\u3092\u3001Node.js\u3092\u4f7f\u3063\u3066<a href=\"https:\/\/www.twilio.com\/docs\/runtime\/functions\" rel=\"noopener\" target=\"_blank\">Twilio Function<\/a>\u4e0a\u306b\u69cb\u7bc9\u3057\u307e\u3059\uff08\u4efb\u610f\u306e\u8a00\u8a9e\u3067\u5b9f\u88c5\u3057\u3001\u3054\u81ea\u8eab\u3067\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30db\u30b9\u30c8\u3059\u308b\u3053\u3068\u3082\u3082\u3061\u308d\u3093\u53ef\u80fd\u3067\u3059\uff09\u3002<\/p>\n<h3>FAX\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h3>\n<p><a href=\"https:\/\/www.twilio.com\/blog\/2018\/05\/how-to-receive-and-download-picture-messages-in-node-js-with-twilio-mms.html\" rel=\"noopener\" target=\"_blank\">\u5225\u306e\u8a18\u4e8b\u3067\u30c1\u30fc\u30e0\u30e1\u30a4\u30c8\u306eSam\u304cMMS\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30e1\u30c7\u30a3\u30a2<\/a>\u3067\u884c\u3063\u3066\u3044\u305f\u3088\u3046\u306b\u3001FAX\u306ePDF\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u308a\u3001<a href=\"https:\/\/sendgrid.kke.co.jp\/docs\/API_Reference\/Web_API_v3\/Mail\/index.html\" rel=\"noopener\" target=\"_blank\">SendGrid\u306eAPI<\/a>\u3092\u547c\u3073\u51fa\u3057\u305f\u308a\u3059\u308b\u306e\u306b\u3001<span style=\"background-color:#d3d3d3\">request<\/span>\u3068\u3044\u3046npm\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5229\u7528\u3057\u307e\u3059\u3002Twilio\u30b3\u30f3\u30bd\u30fc\u30eb\u3067<a href=\"https:\/\/www.twilio.com\/console\/runtime\/functions\/configure\" rel=\"noopener\" target=\"_blank\">Runtime dependencies<\/a>\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u958b\u304d\u3001<span style=\"background-color:#d3d3d3\">request<\/span>\u306e\u30d0\u30fc\u30b8\u30e7\u30f32.88.0\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001<a href=\"https:\/\/app.sendgrid.com\/settings\/api_keys\" rel=\"noopener\" target=\"_blank\">SendGrid\u30a2\u30ab\u30a6\u30f3\u30c8\u4e0a\u3067API\u30ad\u30fc\u3092\u4f5c\u6210<\/a>\uff08\u30e1\u30fc\u30eb\u9001\u4fe1\u306e\u305f\u3081\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u5fc5\u8981\u3067\u3059\uff09\u3057\u3066\u3001<span style=\"background-color:#d3d3d3\">SENDGRID_API_KEY<\/span>\u3068\u3044\u3046\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p>Function\u3092\u69cb\u7bc9\u3059\u308b\u524d\u306b\u3001\u8a2d\u5b9a\u304c\u3042\u30682\u3064\u5fc5\u8981\u3067\u3059\u3002\u305d\u308c\u306f\u3001\u53d7\u4fe1\u3057\u305fFAX\u3092\u9001\u4fe1\u3059\u308b\u5b9b\u5148\u30a2\u30c9\u30ec\u30b9\u3068\u3001\u30e1\u30fc\u30eb\u306e\u9001\u4fe1\u5143\u30a2\u30c9\u30ec\u30b9\u3067\u3059\u3002\u305d\u308c\u305e\u308c\u3001<span style=\"background-color:#d3d3d3\">TO_EMAIL_ADDRESS<\/span>\u3068<span style=\"background-color:#d3d3d3\">FROM_EMAIL_ADDRESS<\/span>\u3068\u3044\u3046\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6b21\u306e\u30d1\u30fc\u30c8\u306b\u79fb\u308b\u524d\u306b\u3001\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>Function\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0<\/h3>\n<p><a href=\"https:\/\/www.twilio.com\/console\/runtime\/functions\/manage\" rel=\"noopener\" target=\"_blank\">\u65b0\u3057\u3044Function<\/a>\u3092\u4f5c\u6210\u3057\u3001Blank\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u9078\u629e\u3057\u307e\u3059\u3002<span style=\"background-color:#d3d3d3\">request<\/span>\u3092require\u3057\u3066\u3001\u30cf\u30f3\u30c9\u30e9\u95a2\u6570\u3092\u4f5c\u6210\u3059\u308b\u3068\u3053\u308d\u304b\u3089\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u958b\u59cb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst request = require('request');\r\nexports.handler = function(context, event, callback) {\r\n}\r\n<\/pre>\n<p>Webhook\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306f\u3001FAX\u3067\u53d7\u4fe1\u3057\u305fPDF\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u6240\u3092\u793a\u3059URL\u3092\u9001\u4fe1\u3057\u3066\u304d\u307e\u3059\u3002\u305d\u306eURL\u306f\u3001<span style=\"background-color:#d3d3d3\">MediaUrl<\/span>\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"background-color:#d3d3d3\">request<\/span>\u3092\u5229\u7528\u3057\u3066PDF\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u305d\u308c\u3092SendGrid\u306eAPI\u3067\u9001\u4fe1\u3059\u308b\u305f\u3081\u306b\u3001<span style=\"background-color:#d3d3d3\">Buffer<\/span>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3044\u3001\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092<span style=\"background-color:#d3d3d3\">null<\/span>\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>Function\u306b\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u52a0\u3057\u307e\u3059\uff1a<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nexports.handler = function(context, event, callback) {\r\n const faxUrl = event.MediaUrl;\r\n\r\n request.get({ uri: faxUrl, encoding: null }, (error, response, body) =&gt; {\r\n   \/\/ body is the PDF file as a Buffer object\r\n });\r\n}\r\n<\/pre>\n<p>\u7d9a\u3044\u3066\u3001<a href=\"https:\/\/sendgrid.kke.co.jp\/docs\/API_Reference\/Web_API_v3\/Mail\/index.html\" rel=\"noopener\" target=\"_blank\">SendGrid API\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u69cb\u7bc9<\/a>\u3057\u307e\u3059\u3002\u4ee5\u524d\u3001<a href=\"https:\/\/www.twilio.com\/blog\/2017\/07\/forward-incoming-sms-messages-to-email-with-node-js-sendgrid-and-twilio-functions.html\" rel=\"noopener\" target=\"_blank\">SMS\u3092\u30e1\u30fc\u30eb\u3068\u3057\u3066\u8ee2\u9001\u3059\u308b\u95a2\u6570\u3092\u4f5c\u3063\u305f\u6642\u306b\u4f7f\u3063\u305f\u65b9\u6cd5<\/a>\u3068\u4f3c\u3066\u3044\u307e\u3059\u3002\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u5185\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\uff1a<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n request.get({ uri: faxUrl, encoding: null }, (error, response, body) =&gt; {\r\n   const email = {\r\n     personalizations: &#x5B;{ to: &#x5B;{ email: context.TO_EMAIL_ADDRESS }] }],\r\n     from: { email: context.FROM_EMAIL_ADDRESS },\r\n     subject: `New fax from ${event.From}`,\r\n     content: &#x5B;\r\n       {\r\n         type: 'text\/plain',\r\n         value: 'Your fax is attached.'\r\n       }\r\n     ],\r\n     attachments: &#x5B;]\r\n   };\r\n   \/\/ more to come\r\n }\r\n<\/pre>\n<p>\u5148\u307b\u3069\u8a2d\u5b9a\u3057\u305f\u74b0\u5883\u5909\u6570\u304b\u3089\u3001<span style=\"background-color:#d3d3d3\">to<\/span>\u3068<span style=\"background-color:#d3d3d3\">from<\/span>\u306b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u4ef6\u540d\u306b\u306f\u65b0\u3057\u3044FAX\u304c\u3042\u308b\u3053\u3068\u304c\u5206\u304b\u308b\u5185\u5bb9\u3092\u3001\u30e1\u30fc\u30eb\u672c\u6587\u306b\u306fFAX\u3067\u53d7\u4fe1\u3057\u305f\u5185\u5bb9\u304c\u6dfb\u4ed8\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u3002\u6700\u5f8c\u306b\u3001\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u914d\u5217\u306b\u53d7\u4fe1\u3057\u305fPDF\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>FAX\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306b\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u5185\u5bb9\u3092\u30e1\u30fc\u30eb\u306b\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u8ffd\u52a0\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u306b\u306f\u30013\u3064\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6301\u3064\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li><span style=\"background-color:#d3d3d3\">content<\/span>: \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305fPDF\u30d5\u30a1\u30a4\u30eb\u306e<span style=\"background-color:#d3d3d3\">Buffer<\/span>\u3092base64\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u6587\u5b57\u5217<\/li>\n<li><span style=\"background-color:#d3d3d3\">filename<\/span>: FAX\u306eSID\u8b58\u5225\u5b50\u304b\u3089\u751f\u6210\u3057\u305f\u6587\u5b57\u5217<\/li>\n<li><span style=\"background-color:#d3d3d3\">type<\/span>: \u30d5\u30a1\u30a4\u30eb\u306eMIME\u30bf\u30a4\u30d7\u3002FAX\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u969b\u306e\u30d8\u30c3\u30c0\u306b\u542b\u307e\u308c\u308b\u3082\u306e\u3092\u305d\u306e\u307e\u307e\u8a2d\u5b9a<\/li>\n<\/ul>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n request.get({ uri: faxUrl, encoding: null }, (error, response, body) =&gt; {\r\n   const email = { ... };\r\n   if (!error &amp;&amp; response.statusCode === 200) {\r\n     email.attachments.push({\r\n       content: body.toString('base64'),\r\n       filename: `${event.FaxSid}.pdf`,\r\n       type: response.headers&#x5B;'content-type']\r\n     });\r\n   }\r\n   \/\/ more to come\r\n }\r\n<\/pre>\n<p>FAX\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306f\u3001\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u306e\u8ffd\u52a0\u3092\u30b9\u30ad\u30c3\u30d7\u3057\u3066\u3001\u901a\u77e5\u30e1\u30fc\u30eb\u3092\u9001\u4fe1\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30e1\u30fc\u30eb\u304c\u69cb\u7bc9\u3067\u304d\u305f\u306e\u3067\u3001SendGrid API\u3092\u547c\u3073\u51fa\u3057\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30e1\u30fc\u30eb\u3092<span style=\"background-color:#d3d3d3\">email<\/span>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u30f3\u30b0\u3057\u305f\u3089\u3001\u5192\u982d\u3067\u4f5c\u6210\u3057\u305fAPI\u30ad\u30fc\u3092\u8a8d\u8a3c\u60c5\u5831\u3068\u3057\u3066\u52a0\u3048\u3066\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/sendgrid.kke.co.jp\/docs\/API_Reference\/Web_API_v3\/Mail\/index.html\" rel=\"noopener\" target=\"_blank\">API\u304c\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9202\u3092\u8fd4\u3057\u3066\u6210\u529f<\/a>\u3057\u305f\u3089\u3001\u7a7a\u306eTwiML<span style=\"background-color:#d3d3d3\">&lt;Response&gt;<\/span>\u3092\u9001\u4fe1\u3057\u3066\u3001Twilio\u306b\u554f\u984c\u304c\u306a\u304b\u3063\u305f\u3053\u3068\u3092\u77e5\u3089\u305b\u307e\u3059\u3002\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306f\u3001\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u7b2c\u4e00\u5f15\u6570\u306berror\u307e\u305f\u306fbody\u3092\u6e21\u3057\u3001Function\u304c\u30a8\u30e9\u30fc\u306b\u306a\u3063\u305f\u3053\u3068\u3092\u30ed\u30b0\u306b\u8a18\u9332\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n request.get({ uri: faxUrl, encoding: null }, (error, response, body) =&gt; {\r\n   const email = { ... };\r\n   if (!error &amp;&amp; response.statusCode == 200) {\r\n     \/\/ add attachment\r\n   }\r\n   request.post(\r\n     {\r\n       uri: 'https:\/\/api.sendgrid.com\/v3\/mail\/send',\r\n       body: email,\r\n       auth: {\r\n         bearer: context.SENDGRID_API_KEY\r\n       },\r\n       json: true\r\n     },\r\n     (error, response, body) =&gt; {\r\n       if (error) {\r\n         return callback(error);\r\n       } else {\r\n         if (response.statusCode === 202) {\r\n           return callback(null, new Twilio.twiml.VoiceResponse());\r\n         } else {\r\n           return callback(body);\r\n         }\r\n       }\r\n     }\r\n   );\r\n }\r\n<\/pre>\n<p>FAX\u3092\u8ee2\u9001\u3059\u308b\u51e6\u7406\u306f\u3053\u308c\u3067\u5168\u3066\u3067\u3059\u3002\u30b3\u30fc\u30c9\u306e\u5168\u4f53\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\uff1a<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst request = require('request');\r\n\r\nexports.handler = function(context, event, callback) {\r\n const faxUrl = event.MediaUrl;\r\n\r\n request.get({ uri: faxUrl, encoding: null }, (error, response, body) =&gt; {\r\n   const email = {\r\n     personalizations: &#x5B;{ to: &#x5B;{ email: context.TO_EMAIL_ADDRESS }] }],\r\n     from: { email: context.FROM_EMAIL_ADDRESS },\r\n     subject: `New fax from ${event.From}`,\r\n     content: &#x5B;\r\n       {\r\n         type: 'text\/plain',\r\n         value: 'Your fax is attached.'\r\n       }\r\n     ],\r\n     attachments: &#x5B;]\r\n   };\r\n   if (!error &amp;&amp; response.statusCode === 200) {\r\n     email.attachments.push({\r\n       content: body.toString('base64'),\r\n       filename: `${event.FaxSid}.pdf`,\r\n       type: response.headers&#x5B;'content-type']\r\n     });\r\n   }\r\n   request.post(\r\n     {\r\n       uri: 'https:\/\/api.sendgrid.com\/v3\/mail\/send',\r\n       body: email,\r\n       auth: {\r\n         bearer: context.SENDGRID_API_KEY\r\n       },\r\n       json: true\r\n     },\r\n     (error, response, body) =&gt; {\r\n       if (error) {\r\n         return callback(error);\r\n       } else {\r\n         if (response.statusCode === 202) {\r\n           return callback(null, new Twilio.twiml.VoiceResponse());\r\n         } else {\r\n           return callback(body);\r\n         }\r\n       }\r\n     }\r\n   );\r\n });\r\n}\r\n<\/pre>\n<p>Function\u306b\u30d1\u30b9\uff08path\uff09\u3092\u8a2d\u5b9a\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<h3>\u4ed5\u4e0a\u3052<\/h3>\n<p>\u7528\u610f\u3057\u305fFAX\u756a\u53f7\u306e\u7de8\u96c6\u753b\u9762\u306b\u623b\u3063\u3066\u3001\u300cVoice &#038; Fax\u300d\u30bb\u30af\u30b7\u30e7\u30f3\u3067FAX\u306e\u7740\u4fe1\u3092\u53d7\u3051\u5165\u308c\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/MuGw-WSEv-fM7PqaF9SDj_-XCAnmcPbHDTLbJDlqibTpKt.width-500.png\" alt=\"Voice &amp; Fax\" width=\"100%\" class=\"aligncenter size-full wp-image-13107\" srcset=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/MuGw-WSEv-fM7PqaF9SDj_-XCAnmcPbHDTLbJDlqibTpKt.width-500.png 500w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/MuGw-WSEv-fM7PqaF9SDj_-XCAnmcPbHDTLbJDlqibTpKt.width-500-300x136.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>\u300cA fax comes in\u300d\u3067<strong>TwiML<\/strong>\u3092\u9078\u629e\u3057\u3001\u8d64\u3044\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u65b0\u3057\u3044TwiML Bin\u3092\u4f5c\u6210\u3057\u3001FAX\u3092\u53d7\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306eTwiML\u3092\u5165\u529b\u3057\u3066\u3001action URL\u3092\u4e0a\u3067\u4f5c\u6210\u3057\u305fFunction\u306eURL\u306b\u7f6e\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;Response&gt;\r\n &lt;Receive action=&quot;FUNCTION_URL&quot; \/&gt;\r\n&lt;\/Response&gt;\r\n<\/pre>\n<p>\u756a\u53f7\u306e\u8a2d\u5b9a\u3092\u4fdd\u5b58\u3057\u305f\u3089\u3001FAX\u3092\u53d7\u4fe1\u3059\u308b\u6e96\u5099\u304c\u6574\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u4eca\u306e\u6642\u4ee3\u3001\u9001\u4fe1\u30c6\u30b9\u30c8\u3092\u3057\u3088\u3046\u306b\u3082FAX\u6a5f\u3092\u6301\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u8fd1\u6240\u306e\u56f3\u66f8\u9928\u3084\u30d7\u30ea\u30f3\u30c8\u30b7\u30e7\u30c3\u30d7\u3067\u501f\u308a\u308b\u304b\u3001<a href=\"https:\/\/www.twilio.com\/login?g=%2Fconsole%2Fruntime%2Fapi-explorer%2Ffax%2Ffax%2Fcreate%3F&#038;t=ad90f787c179c0a656d4527e54da946c85763f1e8d650011ad902592a01bf6d1\" rel=\"noopener\" target=\"_blank\">Twilio\u306eAPI\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u3092\u5229\u7528\u3057\u3066API\u7d4c\u7531\u3067FAX\u3092\u9001\u308a\u307e\u3057\u3087\u3046<\/a>\uff08\u3053\u3053\u3067\u306f\u3001<span style=\"background-color:#d3d3d3\">To<\/span>\u3068<span style=\"background-color:#d3d3d3\">From<\/span>\u3068\u3057\u3066\u65e2\u5b58\u306eFAX\u756a\u53f7\u3092\u5229\u7528\u3067\u304d\u307e\u3059\uff09\u3002FAX\u3092\u9001\u4fe1\u3059\u308b\u969b\u306f\u3001PDF\u30d5\u30a1\u30a4\u30eb\u3092Twilio\u304b\u3089\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u5834\u6240\u306b\u4fdd\u5b58\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u4fdd\u5b58\u5834\u6240\u304c\u306a\u3044\u5834\u5408\u306f\u3001<a href=\"https:\/\/twilio-cms-prod.s3.amazonaws.com\/documents\/justthefaxmaam.pdf\" rel=\"noopener\" target=\"_blank\">\u3053\u3061\u3089\u306e\u30c6\u30b9\u30c8\u7528PDF\u30d5\u30a1\u30a4\u30eb<\/a>\u3092\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u9001\u4fe1\u3059\u308b\u969b\u306f\u3001\u3061\u3083\u3093\u3068<a href=\"https:\/\/www.youtube.com\/watch?v=XC3uDuRXJyA\" rel=\"noopener\" target=\"_blank\">FAX\u306e\u97f3\u3092\u6d41\u3059\u3053\u3068<\/a>\u3092\u5fd8\u308c\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u6570\u5206\u5f85\u3063\u3066\uff08FAX\u306f\u6642\u9593\u304c\u304b\u304b\u308b\u306e\u3067\u3059\uff01\uff09\u3001\u30e1\u30fc\u30eb\u304c\u5c4a\u304f\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/twilio-cms-prod.s3.amazonaws.com\/original_images\/qVB9gqKGzI3BpdDpaKLx1pKlf2LehzYnA4lsnv8qQGfPEB3JeaPzakj-Lz838HPqAdR00xUy3IhBUW\" alt=\"\u6570\u5206\u5f85\u3063\u3066\" width=\"50%\" class=\"aligncenter size-full wp-image-xxxxx\" \/><\/p>\n<p>\u65b0\u3057\u3044FAX\u304c\u5c4a\u3044\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/RVEFYucUVyyCI6soYWUUWazVfhlYKl8nU9aW-REaZUdqr7.width-500.png\" alt=\"\u65b0\u3057\u3044FAX\u304c\u5c4a\u3044\u3066\u3044\u308b\u306f\u305a\" width=\"80%\" class=\"aligncenter size-full wp-image-13106\" srcset=\"https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/RVEFYucUVyyCI6soYWUUWazVfhlYKl8nU9aW-REaZUdqr7.width-500.png 500w, https:\/\/sendgrid.kke.co.jp\/blog\/wp\/wp-content\/uploads\/2020\/10\/RVEFYucUVyyCI6soYWUUWazVfhlYKl8nU9aW-REaZUdqr7.width-500-300x248.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/p>\n<p>\u304a\u3081\u3067\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/twilio-cms-prod.s3.amazonaws.com\/original_images\/mmTCf-XKv4kyX_RW5FafuI_qyD-xIi3ZFym6dVVIje5scqt5AR_HOS78b7lhIsZYBBMZSFyhH9RkHC\" alt=\"\u304a\u3081\u3067\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01\" width=\"50%\" class=\"aligncenter size-full wp-image-xxxxx\" \/><\/p>\n<h3>\u672c\u8a18\u4e8b\u306e\u57f7\u7b46\u306b\u3042\u305f\u308a\u3001FAX\u6a5f\u306b\u88ab\u5bb3\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f<\/h3>\n<p>Twilio\u756a\u53f7\u3001JavaScript\u3001Twilio Function\u3001TwiML Bin,\u305d\u3057\u3066SendGrid API\u306e\u529b\u3067\u30e1\u30fc\u30eb\u30dc\u30c3\u30af\u30b9\u3067\u76f4\u63a5FAX\u3092\u53d7\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><span style=\"background-color:#d3d3d3\">request<\/span>\u3092\u4f7f\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001<a href=\"https:\/\/sendgrid.kke.co.jp\/docs\/API_Reference\/Web_API_v3\/Mail\/index.html\" rel=\"noopener\" target=\"_blank\">SendGrid API<\/a>\u306b\u76f4\u63a5\u6295\u7a3f\u3059\u308b\u65b9\u6cd5\u3092\u898b\u3066\u304d\u307e\u3057\u305f\u3002\u540c\u3058\u30c6\u30af\u30cb\u30c3\u30af\u3092\u4f7f\u3063\u3066\u3001<a href=\"https:\/\/www.twilio.com\/docs\/sms\/tutorials\/how-to-send-sms-messages\" rel=\"noopener\" target=\"_blank\">\u53d7\u4fe1\u3057\u305fMMS\u30e1\u30c3\u30bb\u30fc\u30b8<\/a>\u3092\u30e1\u30fc\u30eb\u306b\u8ee2\u9001\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p> JavaScript\u3068\u30e1\u30fc\u30eb\u3067FAX\u554f\u984c\u3092\u89e3\u6c7a\u3067\u304d\u308b\u306a\u3093\u3066\u60f3\u50cf\u3057\u305f\u3053\u3068\u306f\u3042\u308b\u3067\u3057\u3087\u3046\u304b\uff1f\u4ed6\u306b\u3082\u30af\u30e9\u30b7\u30c3\u30af\u306a\u6280\u8853\u3092\u4eca\u3069\u304d\u306e\u3084\u308a\u65b9\u3067\u7f6e\u304d\u63db\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u4f55\u304b\u3044\u3044\u30a2\u30a4\u30c7\u30a2\u304c\u3042\u3063\u305f\u3089\u305c\u3072<a href=\"https:\/\/twitter.com\/philnash\" rel=\"noopener\" target=\"_blank\">Twitter<\/a>\u3067\u304a\u77e5\u3089\u305b\u304f\u3060\u3055\u3044\uff012020\u5e74\u7248FAX\u4e07\u6b73\uff01<\/p>\n<p>\u30d8\u30c3\u30c0\u30fc\u306eFAX\u30a2\u30a4\u30b3\u30f3\u306fEmojione\u30d0\u30fc\u30b8\u30e7\u30f32\u306e\u63d0\u4f9b\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u306f Forward fax to email with SendGrid and Node.js \u306e\u6284\u8a33\u3067\u3059\u3002 2020\u5e74\u306e\u4eca\u3001FAX\u3092\u53d7\u4fe1\u3057\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u3002\u305d\u3093\u306a\u6642\u3042\u306a\u305f\u306a\u3089\u3069\u3046\u3057\u307e\u3059\u304b\uff1fFAX\u6a5f\u3092\u8cfc\u5165\u3057\u3066\u3001 <a class=\"read-more\" href=\"https:\/\/sendgrid.kke.co.jp\/blog\/?p=13103\">&#8230;\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":13124,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-13103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13103"}],"version-history":[{"count":16,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13103\/revisions"}],"predecessor-version":[{"id":13125,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/13103\/revisions\/13125"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/media\/13124"}],"wp:attachment":[{"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sendgrid.kke.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}